@@ -73,7 +73,7 @@ Synchronous Loading
7373 # Database connection string
7474 DATABASE_URL = " sqlite:///db.sqlite3"
7575
76- config = SQLAlchemySyncConfig(
76+ alchemy_config = SQLAlchemySyncConfig(
7777 engine_instance = create_engine(DATABASE_URL ),
7878 session_config = SyncSessionConfig(expire_on_commit = False )
7979 )
@@ -101,7 +101,7 @@ Synchronous Loading
101101 def initialize_database ():
102102 """ Initialize the database and create tables."""
103103 print (" Creating database tables..." )
104- with config .get_engine().begin() as conn:
104+ with alchemy_config .get_engine().begin() as conn:
105105 UUIDBase.metadata.create_all(conn)
106106 print (" Tables created successfully" )
107107
@@ -111,7 +111,7 @@ Synchronous Loading
111111 print (" Seeding database..." )
112112
113113 # Create a session
114- with config .get_session() as db_session:
114+ with alchemy_config .get_session() as db_session:
115115 # Create repository for product model
116116 product_repo = ProductRepository(session = db_session)
117117
@@ -155,7 +155,7 @@ Asynchronous Loading
155155 # Database connection string
156156 DATABASE_URL = " sqlite+aiosqlite:///db.sqlite3"
157157
158- config = SQLAlchemyAsyncConfig(
158+ alchemy_config = SQLAlchemyAsyncConfig(
159159 engine_instance = create_async_engine(DATABASE_URL ),
160160 session_config = AsyncSessionConfig(expire_on_commit = False )
161161 )
@@ -183,7 +183,7 @@ Asynchronous Loading
183183 async def initialize_database ():
184184 """ Initialize the database and create tables."""
185185 print (" Creating database tables..." )
186- async with config .get_engine().begin() as conn:
186+ async with alchemy_config .get_engine().begin() as conn:
187187 await conn.run_sync(UUIDBase.metadata.create_all)
188188 print (" Tables created successfully" )
189189
@@ -193,7 +193,7 @@ Asynchronous Loading
193193 print (" Seeding database..." )
194194
195195 # Create a session
196- async with config .get_session() as db_session:
196+ async with alchemy_config .get_session() as db_session:
197197 # Create repository for product model
198198 product_repo = ProductRepository(session = db_session)
199199
@@ -256,13 +256,13 @@ Litestar
256256 fixtures_path = Path(__file__ ).parent / " fixtures"
257257
258258 session_config = AsyncSessionConfig(expire_on_commit = False )
259- sqlalchemy_config = SQLAlchemyAsyncConfig(
259+ alchemy_config = SQLAlchemyAsyncConfig(
260260 connection_string = DATABASE_URL ,
261261 before_send_handler = " autocommit" ,
262262 session_config = session_config,
263263 create_all = True ,
264264 )
265- alchemy = SQLAlchemyPlugin(config = sqlalchemy_config )
265+ alchemy = SQLAlchemyPlugin(config = alchemy_config )
266266
267267
268268 class Product (UUIDBase ):
@@ -287,7 +287,7 @@ Litestar
287287 print (" Running startup routine..." )
288288
289289 # Create a session and seed data
290- async with sqlalchemy_config .get_session() as db_session:
290+ async with alchemy_config .get_session() as db_session:
291291 # Create repository for product model
292292 product_repo = ProductRepository(session = db_session)
293293 # Load and add product data
@@ -368,7 +368,7 @@ FastAPI
368368 print (" Running startup routine..." )
369369
370370 # Create a session and seed data
371- async with sqlalchemy_config .get_session() as db_session:
371+ async with alchemy_config .get_session() as db_session:
372372 # Create repository for product model
373373 product_repo = ProductRepository(session = db_session)
374374 # Load and add product data
@@ -394,7 +394,7 @@ FastAPI
394394
395395
396396 session_config = AsyncSessionConfig(expire_on_commit = False )
397- sqlalchemy_config = SQLAlchemyAsyncConfig(
397+ alchemy_config = SQLAlchemyAsyncConfig(
398398 connection_string = DATABASE_URL ,
399399 commit_mode = " autocommit" ,
400400 session_config = session_config,
@@ -404,7 +404,7 @@ FastAPI
404404 # Create the FastAPI application with lifespan
405405 app = FastAPI(lifespan = lifespan)
406406
407- alchemy = AdvancedAlchemy(config = sqlalchemy_config , app = app)
407+ alchemy = AdvancedAlchemy(config = alchemy_config , app = app)
408408
409409 if __name__ == " __main__" :
410410 uvicorn.run(app, host = " 0.0.0.0" , port = 8000 )
@@ -454,7 +454,7 @@ Flask
454454
455455 app = Flask(__name__ )
456456
457- sqlalchemy_config = SQLAlchemySyncConfig(
457+ alchemy_config = SQLAlchemySyncConfig(
458458 connection_string = DATABASE_URL ,
459459 commit_mode = " autocommit" ,
460460 session_config = SyncSessionConfig(
@@ -463,8 +463,8 @@ Flask
463463 create_all = True
464464 )
465465
466- db = AdvancedAlchemy(config = sqlalchemy_config )
467- db .init_app(app)
466+ alchemy = AdvancedAlchemy(config = alchemy_config )
467+ alchemy .init_app(app)
468468
469469 with app.app_context(): # noqa: SIM117
470470 # Seed data
0 commit comments