-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
44 lines (33 loc) · 1.57 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /usr/bin/env python3
import os
from loganalyzer import create_app, db
from flask_script import Manager #, prompt_bool
from flask_migrate import Migrate, MigrateCommand
#from loganalyzer.models import User, SupportBundle, Tag
from datetime import datetime
app = create_app(os.getenv('LOGANALYZER_ENV') or 'dev')
manager = Manager(app)
migrate = Migrate(app, db)
manager.add_command('db', MigrateCommand)
'''
@manager.command
def insert_data():
xzizka = User(username='xzizka',password='Passw0rd',name='Ondrej',surname='Zizka',email='[email protected]')
db.session.add(xzizka)
def add_support_bundle(service_request,filename, comment,path, datetime, tags):
db.session.add(SupportBundle(service_request=service_request, filename=filename, comment=comment, path=path, datetime=datetime, user_id=1, tags=tags))
for name in ["python", "oracle", "support bundle"]:
db.session.add(Tag(name=name))
db.session.commit()
add_support_bundle(3156985, 'nevim.xml', 'komentar 1', '/tmp/nevim.xml', datetime(2016,12,13,hour=12, minute=13,second=52) , 'python')
add_support_bundle(4021369, 'sb.zip', "komentar 2", '/tmp/sb.zip', datetime(2016,12,15,hour=8, minute=1,second=51), 'oracle,support bundle')
add_support_bundle(4021110, 'db_test.log', 'komentar 3', '/tmp/db_test.log', datetime(2017,12,13,hour=1, minute=33,second=0), 'python,oracle')
db.session.commit()
@manager.command
def dbdrop():
if prompt_bool("Do you want to delete all tables?"):
db.drop_all()
print('Tables deleted')
'''
if __name__ == '__main__':
manager.run()