-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
75 lines (50 loc) · 2.35 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#! /usr/bin/env python
import os
from thermos import create_app, db
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
app = create_app(os.getenv('THERMOS_ENV') or 'dev')
manager = Manager(app)
migrate = Migrate(app, db)
manager.add_command('db', MigrateCommand)
if __name__ == '__main__':
manager.run()
"""#! /usr/bin/env python
from thermos import app, db
from thermos.models import User, Bookmark, Tag
from flask_script import Manager, prompt_bool
from flask_migrate import Migrate, MigrateCommand
manager = Manager(app)
migrate = Migrate(app, db)
manager.add_command('db', MigrateCommand)
@manager.command
def insert_data():
gaurav = User(username="gaurav",email="dimpu47@gmail.com",
password="123456")
db.session.add(gaurav)
def add_bookmark(url, description, tags):
db.session.add(Bookmark(url=url, description=description,
user=gaurav, tags=tags))
for name in ["python","flask","webdev","programming","emacs", "go","golang","javascript","dev","angularjs","django","databases","orm","training"]:
db.session.add(Tag(name=name))
db.session.commit()
add_bookmark("http://www.pluralsight.com", "Pluralsight. Hardcore developer training.","training,programming,python,flask,webdev")
add_bookmark("http://www.python.org", "Python - my favorite language","python")
add_bookmark("http://flask.pocoo.org", "Flask: Web development one drop at a time.", "python,flask,webdev")
add_bookmark("http://www.reddit.com", "Reddit. Frontpage of the internet","news,coolstuff,fun")
add_bookmark("http://www.sqlalchemyorg", "Nice ORM framework","python,orm,databases")
add_bookmark("https://golang.org/doc/effective_go.html","Effective Go: The Go programming language","go,golang,programming,dev")
add_bookmark("https://angularjs.org/", "AngularJS: The Superhoic javascript MVW framework","javascript,angularjs")
add_bookmark("https://emacswiki.org/", "Wiki for my favorite editor","emacs")
anonymous = User(username="anonymous", email="anonymous@example.com", password="qwert")
db.session.add(anonymous)
db.session.commit()
print 'Database Initialized.'
@manager.command
def dropdb():
if prompt_bool("Are you sure you want to loose all your data?"):
db.drop_all()
print 'Dropped the database'
if __name__ == '__main__':
manager.run()
"""