File tree Expand file tree Collapse file tree
src/opengeodeweb_microservice/database Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- <h1 align =" center " >OpenGeodeWeb-Back <sup ><i >by Geode-solutions</i ></sup ></h1 >
1+ <h1 align =" center " >OpenGeodeWeb-Microservice <sup ><i >by Geode-solutions</i ></sup ></h1 >
22<h3 align =" center " >OpenSource Python framework based on OpenGeode</h3 >
33
44<p align =" center " >
Original file line number Diff line number Diff line change 1- from flask import Flask
2- from flask_sqlalchemy import SQLAlchemy
31from sqlalchemy .orm import DeclarativeBase
42
53
Original file line number Diff line number Diff line change 88from .base import Base
99
1010DATABASE_FILENAME = "project.db"
11- db : Optional [SQLAlchemy ] = None
11+ database : Optional [SQLAlchemy ] = None
1212
1313
1414def init_database (app : Flask , db_filename : str = DATABASE_FILENAME ) -> SQLAlchemy :
15- global db
16- if db is None :
17- db = SQLAlchemy (model_class = Base )
18- db .init_app (app )
15+ global database
16+ if database is None :
17+ database = SQLAlchemy (model_class = Base )
18+ database .init_app (app )
1919 with app .app_context ():
20- db .create_all ()
21- return db
20+ database .create_all ()
21+ return database
2222
2323
2424def get_database () -> Optional [SQLAlchemy ]:
25- return db
25+ return database
2626
2727
2828def get_session () -> Optional [scoped_session [Session ]]:
29- return db .session if db else None
29+ return database .session if database else None
You can’t perform that action at this time.
0 commit comments