-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_db.py
executable file
·32 lines (26 loc) · 977 Bytes
/
create_db.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
#!/usr/bin/env python
## INFO ##
## INFO ##
# Import python modules
import os.path
# Import SQLAlchemy-migrate modules
from migrate.versioning import api
# Import kibuwiki modules
from config import SQLALCHEMY_DATABASE_URI
from config import SQLALCHEMY_MIGRATE_REPO
from kibuwiki import database
#------------------------------------------------------------------------------#
def main():
database.create_all()
# If repo already exists
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
# If create from scratch
else:
api.version_control(SQLALCHEMY_DATABASE_URI,
SQLALCHEMY_MIGRATE_REPO,
api.version(SQLALCHEMY_MIGRATE_REPO))
#------------------------------------------------------------------------------#
if __name__ == '__main__':
main()