Создана файловая система, main.py и заготовки для создания БД
This commit is contained in:
parent
38533e5b84
commit
974b0973be
1
data/__all_models.py
Normal file
1
data/__all_models.py
Normal file
@ -0,0 +1 @@
|
||||
# from . import user
|
||||
30
data/db_session.py
Normal file
30
data/db_session.py
Normal file
@ -0,0 +1,30 @@
|
||||
import sqlalchemy as sa
|
||||
import sqlalchemy.orm as orm
|
||||
from sqlalchemy.orm import Session
|
||||
import sqlalchemy.ext.declarative as dec
|
||||
|
||||
SqlAlchemyBase = dec.declarative_base()
|
||||
|
||||
__factory = None
|
||||
|
||||
def global_init(db_file):
|
||||
global __factory
|
||||
|
||||
if __factory:
|
||||
return
|
||||
|
||||
if not db_file or not db_file.strip():
|
||||
raise Exception("Необходимо указать файл базы данных.")
|
||||
|
||||
conn_str = f'sqlite:///{db_file.strip()}?check_same_thread=False'
|
||||
|
||||
engine = sa.create_engine(conn_str, echo=False)
|
||||
__factory = orm.sessionmaker(bind=engine)
|
||||
|
||||
from . import __all_models
|
||||
|
||||
SqlAlchemyBase.metadata.create_all(engine)
|
||||
|
||||
def create_session() -> Session:
|
||||
global __factory
|
||||
return __factory()
|
||||
0
docs/заглушка
Normal file
0
docs/заглушка
Normal file
20
main.py
Normal file
20
main.py
Normal file
@ -0,0 +1,20 @@
|
||||
from flask import Flask
|
||||
from waitress import serve
|
||||
from data import db_session
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config['SECRET_KEY'] = 'test_secret_key'
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def base():
|
||||
return ''
|
||||
|
||||
|
||||
def main():
|
||||
db_session.global_init("db/conventus.db")
|
||||
serve(app, host='0.0.0.0', port=5000)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
0
static/app_image/заглушка
Normal file
0
static/app_image/заглушка
Normal file
0
static/css/заглушка
Normal file
0
static/css/заглушка
Normal file
0
static/js/заглушка
Normal file
0
static/js/заглушка
Normal file
0
static/main_image/заглушка
Normal file
0
static/main_image/заглушка
Normal file
0
templates/заглушка
Normal file
0
templates/заглушка
Normal file
Loading…
x
Reference in New Issue
Block a user