@@ -251,9 +251,17 @@ Basic Migration Config
251251
252252**Migration CLI **
253253
254- .. literalinclude :: /examples/usage/test_configuration_22.txt
255- :language: text
256- :caption: `migration CLI `
254+ .. code-block :: bash
255+
256+ # Create migration
257+ sqlspec --config myapp.config create-migration -m " Add users table"
258+
259+ # Apply migrations
260+ sqlspec --config myapp.config upgrade
261+
262+ # Rollback
263+ sqlspec --config myapp.config downgrade -1
264+
257265
258266
259267 Extension Migration Versioning
@@ -281,42 +289,22 @@ Framework integrations can be configured via ``extension_config``.
281289Litestar Plugin Configuration
282290^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
283291
284- .. code-block :: python
285-
286- from sqlspec.adapters.asyncpg import AsyncpgConfig
287-
288- config = AsyncpgConfig(
289- pool_config = {" dsn" : " postgresql://localhost/db" },
290- extension_config = {
291- " litestar" : {
292- " connection_key" : " db_connection" ,
293- " session_key" : " db_session" ,
294- " pool_key" : " db_pool" ,
295- " commit_mode" : " autocommit" ,
296- " enable_correlation_middleware" : True ,
297- }
298- }
299- )
292+ .. literalinclude :: /examples/usage/test_configuration_23.py
293+ :language: python
294+ :caption: `litestar plugin configuration `
295+ :lines: 10-31
296+ :dedent: 2
300297
301298Environment-Based Configuration
302299-------------------------------
303300
304301Use environment variables for configuration:
305302
306- .. code-block :: python
307-
308- import os
309- from sqlspec.adapters.asyncpg import AsyncpgConfig
310-
311- config = AsyncpgConfig(
312- pool_config = {
313- " host" : os.getenv(" DB_HOST" , " localhost" ),
314- " port" : int (os.getenv(" DB_PORT" , " 5432" )),
315- " user" : os.getenv(" DB_USER" ),
316- " password" : os.getenv(" DB_PASSWORD" ),
317- " database" : os.getenv(" DB_NAME" ),
318- }
319- )
303+ .. literalinclude :: /examples/usage/test_configuration_23.py
304+ :language: python
305+ :caption: `environnment-based configuration `
306+ :lines: 49-59
307+ :dedent: 4
320308
321309Configuration Best Practices
322310-----------------------------
@@ -325,59 +313,52 @@ Configuration Best Practices
325313
326314Always use pooling in production:
327315
328- .. code-block :: python
329-
330- config = AsyncpgConfig(
331- pool_config = {
332- " dsn" : " postgresql://localhost/db" ,
333- " min_size" : 10 ,
334- " max_size" : 20 ,
335- }
336- )
316+ .. literalinclude :: /examples/usage/test_configuration_24.py
317+ :language: python
318+ :caption: `connection pooling `
319+ :lines: 11-13
320+ :dedent: 2
337321
338322**2. Enable Caching **
339323
340324Enable caching to avoid recompiling SQL statements:
341325
342- .. code-block :: python
343-
344- statement_config = StatementConfig(
345- dialect = " postgres" ,
346- enable_caching = True
347- )
326+ .. literalinclude :: /examples/usage/test_configuration_25.py
327+ :language: python
328+ :caption: `enable caching `
329+ :lines: 6-8
330+ :dedent: 2
348331
349332**3. Tune Pool Sizes **
350333
351334Size pools based on your workload:
352335
353- .. code-block :: python
354-
355- # CPU-bound workload
356- pool_config = {" min_size" : 5 , " max_size" : 10 }
357-
358- # I/O-bound workload
359- pool_config = {" min_size" : 20 , " max_size" : 50 }
336+ .. literalinclude :: /examples/usage/test_configuration_26.py
337+ :language: python
338+ :caption: `tune pool sizes `
339+ :lines: 6-14
340+ :dedent: 2
360341
361342**4. Disable Validation in Production **
362343
363344For trusted, performance-critical queries:
364345
365- .. code-block :: python
346+ .. literalinclude :: /examples/usage/test_configuration_26.py
347+ :language: python
348+ :caption: `no validation `
349+ :lines: 19-25
350+ :dedent: 2
366351
367- statement_config = StatementConfig(
368- dialect = " postgres" ,
369- enable_validation = False , # Skip security checks
370- )
371352
372353**5. Clean Up Resources **
373354
374355Always close pools on shutdown:
375356
376- .. code-block :: python
377-
378- # Synchronous cleanup (automatic with atexit)
379- # Asynchronous cleanup (manual)
380- await spec.close_all_pools()
357+ .. literalinclude :: /examples/usage/test_configuration_27.py
358+ :language: python
359+ :caption: ` cleanup resources `
360+ :lines: 10-27
361+ :dedent: 2
381362
382363Next Steps
383364----------
0 commit comments