File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
src/opengeodeweb_microservice/database Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 1111scoped_session_registry = None
1212
1313
14- def init_database (db_path : str = DATABASE_FILENAME ) -> None :
14+ def init_database (db_path : str = DATABASE_FILENAME , create_tables : bool = True ) -> None :
1515 global engine , session_factory , scoped_session_registry
1616
1717 if engine is None :
@@ -22,8 +22,11 @@ def init_database(db_path: str = DATABASE_FILENAME) -> None:
2222 print (f"Database engine created for { db_path } " , flush = True )
2323 session_factory = sessionmaker (bind = engine )
2424 scoped_session_registry = scoped_session (session_factory )
25- Base .metadata .create_all (engine )
26- print (f"Database engine created DONE for { db_path } " )
25+ if create_tables :
26+ Base .metadata .create_all (engine )
27+ print (f"Database tables created for { db_path } " , flush = True )
28+ else :
29+ print (f"Database connected (tables not created) for { db_path } " , flush = True )
2730 else :
2831 print (f"Database engine already exists for { db_path } , reusing" , flush = True )
2932
You can’t perform that action at this time.
0 commit comments