-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
shenshuo
committed
Dec 24, 2018
1 parent
7f3fa3f
commit 43b71e8
Showing
5 changed files
with
54 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Contact : [email protected] | ||
Author : shenshuo | ||
Date : 2018/12/24 | ||
Desc : | ||
""" | ||
|
||
from models.cron import Base | ||
from websdk.consts import const | ||
from settings import settings as app_settings | ||
# ORM创建表结构 | ||
from sqlalchemy import create_engine | ||
|
||
default_configs = app_settings[const.DB_CONFIG_ITEM][const.DEFAULT_DB_KEY] | ||
engine = create_engine('mysql+pymysql://%s:%s@%s:%s/%s?charset=utf8' % ( | ||
default_configs.get(const.DBUSER_KEY), | ||
default_configs.get(const.DBPWD_KEY), | ||
default_configs.get(const.DBHOST_KEY), | ||
default_configs.get(const.DBPORT_KEY), | ||
default_configs.get(const.DBNAME_KEY), | ||
), encoding='utf-8', echo=True) | ||
|
||
|
||
def create(): | ||
Base.metadata.create_all(engine) | ||
print('[Success] 表结构创建成功!') | ||
|
||
|
||
def drop(): | ||
Base.metadata.drop_all(engine) | ||
|
||
|
||
if __name__ == '__main__': | ||
create() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters