sqlspec 0.20.0__tar.gz → 0.21.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sqlspec might be problematic. Click here for more details.

Files changed (325) hide show
  1. {sqlspec-0.20.0 → sqlspec-0.21.1}/PKG-INFO +230 -44
  2. {sqlspec-0.20.0 → sqlspec-0.21.1}/README.md +229 -43
  3. {sqlspec-0.20.0 → sqlspec-0.21.1}/pyproject.toml +6 -5
  4. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/driver/mixins/_result_tools.py +41 -6
  5. sqlspec-0.21.1/sqlspec/extensions/litestar/config.py +276 -0
  6. sqlspec-0.21.1/sqlspec/extensions/litestar/plugin.py +386 -0
  7. sqlspec-0.21.1/sqlspec/utils/data_transformation.py +120 -0
  8. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/text.py +27 -19
  9. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/type_guards.py +74 -0
  10. sqlspec-0.21.1/tests/unit/test_extensions/__init__.py +1 -0
  11. sqlspec-0.21.1/tests/unit/test_extensions/test_litestar/__init__.py +1 -0
  12. sqlspec-0.21.1/tests/unit/test_extensions/test_litestar/test_config.py +482 -0
  13. sqlspec-0.21.1/tests/unit/test_utils/test_data_transformation.py +343 -0
  14. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_text.py +1 -36
  15. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_type_guards.py +105 -0
  16. {sqlspec-0.20.0 → sqlspec-0.21.1}/uv.lock +247 -219
  17. sqlspec-0.20.0/sqlspec/extensions/litestar/config.py +0 -92
  18. sqlspec-0.20.0/sqlspec/extensions/litestar/plugin.py +0 -152
  19. {sqlspec-0.20.0 → sqlspec-0.21.1}/.gitignore +0 -0
  20. {sqlspec-0.20.0 → sqlspec-0.21.1}/.pre-commit-config.yaml +0 -0
  21. {sqlspec-0.20.0 → sqlspec-0.21.1}/CONTRIBUTING.rst +0 -0
  22. {sqlspec-0.20.0 → sqlspec-0.21.1}/LICENSE +0 -0
  23. {sqlspec-0.20.0 → sqlspec-0.21.1}/Makefile +0 -0
  24. {sqlspec-0.20.0 → sqlspec-0.21.1}/NOTICE +0 -0
  25. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/__init__.py +0 -0
  26. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/__main__.py +0 -0
  27. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/__metadata__.py +0 -0
  28. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/_serialization.py +0 -0
  29. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/_sql.py +0 -0
  30. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/_typing.py +0 -0
  31. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/__init__.py +0 -0
  32. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/adbc/__init__.py +0 -0
  33. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/adbc/_types.py +0 -0
  34. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/adbc/config.py +0 -0
  35. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/adbc/driver.py +0 -0
  36. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/aiosqlite/__init__.py +0 -0
  37. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/aiosqlite/_types.py +0 -0
  38. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/aiosqlite/config.py +0 -0
  39. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/aiosqlite/driver.py +0 -0
  40. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/aiosqlite/pool.py +0 -0
  41. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncmy/__init__.py +0 -0
  42. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncmy/_types.py +0 -0
  43. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncmy/config.py +0 -0
  44. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncmy/driver.py +0 -0
  45. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncpg/__init__.py +0 -0
  46. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncpg/_types.py +0 -0
  47. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncpg/config.py +0 -0
  48. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncpg/driver.py +0 -0
  49. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/bigquery/__init__.py +0 -0
  50. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/bigquery/_types.py +0 -0
  51. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/bigquery/config.py +0 -0
  52. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/bigquery/driver.py +0 -0
  53. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/duckdb/__init__.py +0 -0
  54. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/duckdb/_types.py +0 -0
  55. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/duckdb/config.py +0 -0
  56. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/duckdb/driver.py +0 -0
  57. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/duckdb/pool.py +0 -0
  58. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/oracledb/__init__.py +0 -0
  59. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/oracledb/_types.py +0 -0
  60. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/oracledb/config.py +0 -0
  61. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/oracledb/driver.py +0 -0
  62. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/oracledb/migrations.py +0 -0
  63. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psqlpy/__init__.py +0 -0
  64. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psqlpy/_types.py +0 -0
  65. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psqlpy/config.py +0 -0
  66. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psqlpy/driver.py +0 -0
  67. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psycopg/__init__.py +0 -0
  68. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psycopg/_types.py +0 -0
  69. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psycopg/config.py +0 -0
  70. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psycopg/driver.py +0 -0
  71. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/sqlite/__init__.py +0 -0
  72. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/sqlite/_types.py +0 -0
  73. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/sqlite/config.py +0 -0
  74. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/sqlite/driver.py +0 -0
  75. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/sqlite/pool.py +0 -0
  76. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/base.py +0 -0
  77. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/__init__.py +0 -0
  78. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_base.py +0 -0
  79. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_column.py +0 -0
  80. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_ddl.py +0 -0
  81. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_delete.py +0 -0
  82. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_expression_wrappers.py +0 -0
  83. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_insert.py +0 -0
  84. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_merge.py +0 -0
  85. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_parsing_utils.py +0 -0
  86. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_select.py +0 -0
  87. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_update.py +0 -0
  88. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/__init__.py +0 -0
  89. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_cte_and_set_ops.py +0 -0
  90. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_delete_operations.py +0 -0
  91. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_insert_operations.py +0 -0
  92. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_join_operations.py +0 -0
  93. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_merge_operations.py +0 -0
  94. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_order_limit_operations.py +0 -0
  95. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_pivot_operations.py +0 -0
  96. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_select_operations.py +0 -0
  97. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_update_operations.py +0 -0
  98. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_where_clause.py +0 -0
  99. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/cli.py +0 -0
  100. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/config.py +0 -0
  101. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/__init__.py +0 -0
  102. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/cache.py +0 -0
  103. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/compiler.py +0 -0
  104. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/filters.py +0 -0
  105. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/hashing.py +0 -0
  106. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/parameters.py +0 -0
  107. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/result.py +0 -0
  108. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/splitter.py +0 -0
  109. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/statement.py +0 -0
  110. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/driver/__init__.py +0 -0
  111. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/driver/_async.py +0 -0
  112. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/driver/_common.py +0 -0
  113. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/driver/_sync.py +0 -0
  114. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/driver/mixins/__init__.py +0 -0
  115. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/driver/mixins/_sql_translator.py +0 -0
  116. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/exceptions.py +0 -0
  117. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/__init__.py +0 -0
  118. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/aiosql/__init__.py +0 -0
  119. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/aiosql/adapter.py +0 -0
  120. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/litestar/__init__.py +0 -0
  121. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/litestar/_utils.py +0 -0
  122. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/litestar/cli.py +0 -0
  123. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/litestar/handlers.py +0 -0
  124. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/litestar/providers.py +0 -0
  125. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/loader.py +0 -0
  126. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/migrations/__init__.py +0 -0
  127. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/migrations/base.py +0 -0
  128. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/migrations/commands.py +0 -0
  129. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/migrations/loaders.py +0 -0
  130. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/migrations/runner.py +0 -0
  131. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/migrations/tracker.py +0 -0
  132. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/migrations/utils.py +0 -0
  133. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/protocols.py +0 -0
  134. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/py.typed +0 -0
  135. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/storage/__init__.py +0 -0
  136. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/storage/backends/__init__.py +0 -0
  137. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/storage/backends/base.py +0 -0
  138. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/storage/backends/fsspec.py +0 -0
  139. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/storage/backends/obstore.py +0 -0
  140. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/storage/capabilities.py +0 -0
  141. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/storage/registry.py +0 -0
  142. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/typing.py +0 -0
  143. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/__init__.py +0 -0
  144. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/correlation.py +0 -0
  145. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/deprecation.py +0 -0
  146. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/fixtures.py +0 -0
  147. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/logging.py +0 -0
  148. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/module_loader.py +0 -0
  149. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/serializers.py +0 -0
  150. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/singleton.py +0 -0
  151. {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/sync_tools.py +0 -0
  152. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/__init__.py +0 -0
  153. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/conftest.py +0 -0
  154. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/__init__.py +0 -0
  155. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/asset_maintenance.sql +0 -0
  156. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/ddls-mysql-collection.sql +0 -0
  157. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/ddls-postgres-collection.sql +0 -0
  158. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/example_usage.py +0 -0
  159. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/init.sql +0 -0
  160. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-config.sql +0 -0
  161. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-data_types.sql +0 -0
  162. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-database_details.sql +0 -0
  163. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-engines.sql +0 -0
  164. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-hostname.sql +0 -0
  165. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-plugins.sql +0 -0
  166. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-process_list.sql +0 -0
  167. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-resource-groups.sql +0 -0
  168. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-schema_objects.sql +0 -0
  169. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-table_details.sql +0 -0
  170. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-users.sql +0 -0
  171. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/init.sql +0 -0
  172. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/oracle.ddl.sql +0 -0
  173. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-applications.sql +0 -0
  174. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-aws_extension_dependency.sql +0 -0
  175. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-aws_oracle_exists.sql +0 -0
  176. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-bg_writer_stats.sql +0 -0
  177. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-calculated_metrics.sql +0 -0
  178. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-data_types.sql +0 -0
  179. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-database_details.sql +0 -0
  180. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-extensions.sql +0 -0
  181. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-index_details.sql +0 -0
  182. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-pglogical-details.sql +0 -0
  183. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-privileges.sql +0 -0
  184. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-replication_slots.sql +0 -0
  185. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-replication_stats.sql +0 -0
  186. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-schema_details.sql +0 -0
  187. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-schema_objects.sql +0 -0
  188. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-settings.sql +0 -0
  189. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-source_details.sql +0 -0
  190. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-table_details.sql +0 -0
  191. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/extended-collection-all-databases.sql +0 -0
  192. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/init.sql +0 -0
  193. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/readiness-check.sql +0 -0
  194. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/sql_utils.py +0 -0
  195. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/__init__.py +0 -0
  196. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/conftest.py +0 -0
  197. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/__init__.py +0 -0
  198. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/__init__.py +0 -0
  199. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/conftest.py +0 -0
  200. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_adbc_arrow_features.py +0 -0
  201. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_adbc_backends.py +0 -0
  202. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_adbc_connection.py +0 -0
  203. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_adbc_driver.py +0 -0
  204. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_adbc_edge_cases.py +0 -0
  205. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_adbc_results.py +0 -0
  206. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_migrations.py +0 -0
  207. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_parameter_styles.py +0 -0
  208. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_aiosqlite/__init__.py +0 -0
  209. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_aiosqlite/conftest.py +0 -0
  210. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_aiosqlite/test_connection.py +0 -0
  211. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_aiosqlite/test_driver.py +0 -0
  212. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_aiosqlite/test_migrations.py +0 -0
  213. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_aiosqlite/test_parameter_styles.py +0 -0
  214. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_aiosqlite/test_pooling.py +0 -0
  215. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncmy/__init__.py +0 -0
  216. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncmy/conftest.py +0 -0
  217. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncmy/test_asyncmy_features.py +0 -0
  218. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncmy/test_config.py +0 -0
  219. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncmy/test_driver.py +0 -0
  220. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncmy/test_migrations.py +0 -0
  221. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncmy/test_parameter_styles.py +0 -0
  222. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncpg/__init__.py +0 -0
  223. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncpg/conftest.py +0 -0
  224. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncpg/test_connection.py +0 -0
  225. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncpg/test_driver.py +0 -0
  226. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncpg/test_execute_many.py +0 -0
  227. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncpg/test_migrations.py +0 -0
  228. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncpg/test_parameter_styles.py +0 -0
  229. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_bigquery/__init__.py +0 -0
  230. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_bigquery/conftest.py +0 -0
  231. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_bigquery/test_bigquery_features.py +0 -0
  232. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_bigquery/test_config.py +0 -0
  233. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_bigquery/test_connection.py +0 -0
  234. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_bigquery/test_driver.py +0 -0
  235. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/__init__.py +0 -0
  236. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/test_connection.py +0 -0
  237. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/test_driver.py +0 -0
  238. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/test_execute_many.py +0 -0
  239. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/test_migrations.py +0 -0
  240. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/test_mixed_parameter_styles.py +0 -0
  241. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/test_parameter_styles.py +0 -0
  242. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/test_pooling.py +0 -0
  243. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/utils.py +0 -0
  244. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/__init__.py +0 -0
  245. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/conftest.py +0 -0
  246. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/test_connection.py +0 -0
  247. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/test_driver_async.py +0 -0
  248. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/test_driver_sync.py +0 -0
  249. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/test_execute_many.py +0 -0
  250. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/test_migrations.py +0 -0
  251. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/test_oracle_features.py +0 -0
  252. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/test_parameter_styles.py +0 -0
  253. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psqlpy/__init__.py +0 -0
  254. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psqlpy/conftest.py +0 -0
  255. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psqlpy/test_connection.py +0 -0
  256. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psqlpy/test_driver.py +0 -0
  257. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psqlpy/test_migrations.py +0 -0
  258. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psqlpy/test_parameter_styles.py +0 -0
  259. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psqlpy/test_psqlpy_features.py +0 -0
  260. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/__init__.py +0 -0
  261. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/conftest.py +0 -0
  262. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/test_async_copy.py +0 -0
  263. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/test_connection.py +0 -0
  264. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/test_driver.py +0 -0
  265. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/test_execute_many.py +0 -0
  266. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/test_migrations.py +0 -0
  267. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/test_parameter_styles.py +0 -0
  268. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_sqlite/__init__.py +0 -0
  269. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_sqlite/conftest.py +0 -0
  270. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_sqlite/test_driver.py +0 -0
  271. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_sqlite/test_migrations.py +0 -0
  272. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_sqlite/test_parameter_styles.py +0 -0
  273. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_sqlite/test_pooling.py +0 -0
  274. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_sqlite/test_query_mixin.py +0 -0
  275. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_loader/__init__.py +0 -0
  276. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_loader/test_file_system_loading.py +0 -0
  277. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_migrations/__init__.py +0 -0
  278. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/conftest.py +0 -0
  279. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_adapters/__init__.py +0 -0
  280. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_adapters/conftest.py +0 -0
  281. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_adapters/test_adapter_implementations.py +0 -0
  282. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_adapters/test_async_adapters.py +0 -0
  283. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_adapters/test_sync_adapters.py +0 -0
  284. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_base/__init__.py +0 -0
  285. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_base/test_sql_integration.py +0 -0
  286. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_base/test_sqlspec_class.py +0 -0
  287. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_builder/__init__.py +0 -0
  288. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_builder/test_insert_builder.py +0 -0
  289. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_builder/test_parameter_naming.py +0 -0
  290. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_builder_parameter_naming.py +0 -0
  291. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_core/test_cache.py +0 -0
  292. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_core/test_compiler.py +0 -0
  293. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_core/test_filters.py +0 -0
  294. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_core/test_hashing.py +0 -0
  295. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_core/test_parameters.py +0 -0
  296. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_core/test_result.py +0 -0
  297. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_core/test_statement.py +0 -0
  298. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_loader/__init__.py +0 -0
  299. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_loader/test_cache_integration.py +0 -0
  300. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_loader/test_fixtures_directory_loading.py +0 -0
  301. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_loader/test_loading_patterns.py +0 -0
  302. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_loader/test_sql_file_loader.py +0 -0
  303. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_migrations/__init__.py +0 -0
  304. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_migrations/test_migration.py +0 -0
  305. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_migrations/test_migration_commands.py +0 -0
  306. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_migrations/test_migration_execution.py +0 -0
  307. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_migrations/test_migration_runner.py +0 -0
  308. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_parsing_utils.py +0 -0
  309. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_sql_factory.py +0 -0
  310. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/__init__.py +0 -0
  311. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_correlation.py +0 -0
  312. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_deprecation.py +0 -0
  313. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_fixtures.py +0 -0
  314. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_logging.py +0 -0
  315. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_module_loader.py +0 -0
  316. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_serializers.py +0 -0
  317. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_singleton.py +0 -0
  318. {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_sync_tools.py +0 -0
  319. {sqlspec-0.20.0 → sqlspec-0.21.1}/tools/__init__.py +0 -0
  320. {sqlspec-0.20.0 → sqlspec-0.21.1}/tools/build_docs.py +0 -0
  321. {sqlspec-0.20.0 → sqlspec-0.21.1}/tools/local-infra.sh +0 -0
  322. {sqlspec-0.20.0 → sqlspec-0.21.1}/tools/pypi_readme.py +0 -0
  323. {sqlspec-0.20.0 → sqlspec-0.21.1}/tools/sphinx_ext/__init__.py +0 -0
  324. {sqlspec-0.20.0 → sqlspec-0.21.1}/tools/sphinx_ext/changelog.py +0 -0
  325. {sqlspec-0.20.0 → sqlspec-0.21.1}/tools/sphinx_ext/missing_references.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlspec
3
- Version: 0.20.0
3
+ Version: 0.21.1
4
4
  Summary: SQL Experiments in Python
5
5
  Project-URL: Discord, https://discord.gg/litestar
6
6
  Project-URL: Issue, https://github.com/litestar-org/sqlspec/issues/
@@ -130,16 +130,21 @@ These are just a few examples that demonstrate SQLSpec's flexibility. Each of th
130
130
  ```python
131
131
  from sqlspec import SQLSpec
132
132
  from sqlspec.adapters.sqlite import SqliteConfig
133
- from pydantic import BaseModel
133
+
134
134
  # Create SQLSpec instance and configure database
135
- sql = SQLSpec()
136
- config = sql.add_config(SqliteConfig(database=":memory:"))
135
+ db_manager = SQLSpec()
136
+ config = SqliteConfig(pool_config={"database": ":memory:"}) # Thread local pooling
137
+ db_manager.add_config(config)
137
138
 
138
139
  # Execute queries with automatic result mapping
139
- with sql.provide_session(config) as session:
140
+ with db_manager.provide_session(config) as session:
140
141
  # Simple query
141
142
  result = session.execute("SELECT 'Hello, SQLSpec!' as message")
142
143
  print(result.get_first()) # {'message': 'Hello, SQLSpec!'}
144
+
145
+ # Type-safe single row query
146
+ row = session.select_one("SELECT 'Hello, SQLSpec!' as message")
147
+ print(row) # {'message': 'Hello, SQLSpec!'}
143
148
  ```
144
149
 
145
150
  ### SQL Builder Example (Experimental)
@@ -150,30 +155,94 @@ with sql.provide_session(config) as session:
150
155
  from sqlspec import sql
151
156
 
152
157
  # Build a simple query
153
- query = sql.select("id", "name", "email").from_("users").where("active = ?", True)
154
- print(query.build().sql) # SELECT id, name, email FROM users WHERE active = ?
158
+ query = sql.select("id", "name", "email").from_("users").where("active = ?")
159
+ statement = query.to_statement()
160
+ print(statement.sql) # SELECT id, name, email FROM users WHERE active = ?
155
161
 
156
162
  # More complex example with joins
157
163
  query = (
158
164
  sql.select("u.name", "COUNT(o.id) as order_count")
159
165
  .from_("users u")
160
166
  .left_join("orders o", "u.id = o.user_id")
161
- .where("u.created_at > ?", "2024-01-01")
167
+ .where("u.created_at > ?")
162
168
  .group_by("u.name")
163
- .having("COUNT(o.id) > ?", 5)
169
+ .having("COUNT(o.id) > ?")
164
170
  .order_by("order_count", desc=True)
165
171
  )
166
172
 
167
- # Execute the built query
168
- with sql.provide_session(config) as session:
169
- results = session.execute(query.build())
173
+ # Execute the built query with parameters
174
+ with db_manager.provide_session(config) as session:
175
+ results = session.execute(query, "2024-01-01", 5)
176
+ ```
177
+
178
+ ### Type-Safe Result Mapping
179
+
180
+ SQLSpec supports automatic mapping to typed models using popular libraries:
181
+
182
+ ```python
183
+ from sqlspec import SQLSpec
184
+ from sqlspec.adapters.sqlite import SqliteConfig
185
+ from pydantic import BaseModel
186
+
187
+ class User(BaseModel):
188
+ id: int
189
+ name: str
190
+ email: str
191
+
192
+ db_manager = SQLSpec()
193
+ config = SqliteConfig(pool_config={"database": ":memory:"})
194
+ db_manager.add_config(config)
195
+
196
+ with db_manager.provide_session(config) as session:
197
+ # Create and populate test data
198
+ session.execute_script("""
199
+ CREATE TABLE users (id INTEGER, name TEXT, email TEXT);
200
+ INSERT INTO users VALUES (1, 'Alice', 'alice@example.com');
201
+ """)
202
+ # Map single result to typed model
203
+ user = session.select_one("SELECT * FROM users WHERE id = ?", 1, schema_type=User)
204
+ print(f"User: {user.name} ({user.email})")
205
+
206
+ # Map multiple results
207
+ users = session.select("SELECT * FROM users", schema_type=User)
208
+ for user in users:
209
+ print(f"User: {user.name}")
210
+ ```
211
+
212
+ ### Session Methods Overview
213
+
214
+ SQLSpec provides several convenient methods for executing queries:
215
+
216
+ ```python
217
+ with db_manager.provide_session(config) as session:
218
+ # Execute any SQL and get full result set
219
+ result = session.execute("SELECT * FROM users")
220
+
221
+ # Get single row (raises error if not found)
222
+ user = session.select_one("SELECT * FROM users WHERE id = ?", 1)
223
+
224
+ # Get single row or None (no error if not found)
225
+ maybe_user = session.select_one_or_none("SELECT * FROM users WHERE id = ?", 999)
226
+
227
+ # Execute with many parameter sets (bulk operations)
228
+ session.execute_many(
229
+ "INSERT INTO users (name, email) VALUES (?, ?)",
230
+ [("Bob", "bob@example.com"), ("Carol", "carol@example.com")]
231
+ )
232
+
233
+ # Execute multiple statements as a script
234
+ session.execute_script("""
235
+ CREATE TABLE IF NOT EXISTS logs (id INTEGER, message TEXT);
236
+ INSERT INTO logs (message) VALUES ('System started');
237
+ """)
170
238
  ```
171
239
 
172
- ### DuckDB LLM
240
+ <details>
241
+ <summary>🦆 DuckDB LLM Integration Example</summary>
173
242
 
174
243
  This is a quick implementation using some of the built-in Secret and Extension management features of SQLSpec's DuckDB integration.
175
244
 
176
- It allows you to communicate with any compatible OpenAPI conversations endpoint (such as Ollama). This example:
245
+ It allows you to communicate with any compatible OpenAI conversations endpoint (such as Ollama). This example:
177
246
 
178
247
  - auto installs the `open_prompt` DuckDB extensions
179
248
  - automatically creates the correct `open_prompt` compatible secret required to use the extension
@@ -193,11 +262,12 @@ from pydantic import BaseModel
193
262
  class ChatMessage(BaseModel):
194
263
  message: str
195
264
 
196
- sql = SQLSpec()
197
- etl_config = sql.add_config(
198
- DuckDBConfig(
199
- extensions=[{"name": "open_prompt"}],
200
- secrets=[
265
+ db_manager = SQLSpec()
266
+ config = DuckDBConfig(
267
+ pool_config={"database": ":memory:"},
268
+ driver_features={
269
+ "extensions": [{"name": "open_prompt"}],
270
+ "secrets": [
201
271
  {
202
272
  "secret_type": "open_prompt",
203
273
  "name": "open_prompt",
@@ -208,9 +278,11 @@ etl_config = sql.add_config(
208
278
  },
209
279
  }
210
280
  ],
211
- )
281
+ },
212
282
  )
213
- with sql.provide_session(etl_config) as session:
283
+ db_manager.add_config(config)
284
+
285
+ with db_manager.provide_session(config) as session:
214
286
  result = session.select_one(
215
287
  "SELECT open_prompt(?)",
216
288
  "Can you write a haiku about DuckDB?",
@@ -219,7 +291,10 @@ with sql.provide_session(etl_config) as session:
219
291
  print(result) # result is a ChatMessage pydantic model
220
292
  ```
221
293
 
222
- ### DuckDB Gemini Embeddings
294
+ </details>
295
+
296
+ <details>
297
+ <summary>🔗 DuckDB Gemini Embeddings Example</summary>
223
298
 
224
299
  In this example, we are again using DuckDB. However, we are going to use the built-in to call the Google Gemini embeddings service directly from the database.
225
300
 
@@ -246,11 +321,12 @@ API_URL = (
246
321
  f"https://generativelanguage.googleapis.com/v1beta/models/{EMBEDDING_MODEL}:embedContent?key=${GOOGLE_API_KEY}"
247
322
  )
248
323
 
249
- sql = SQLSpec()
250
- etl_config = sql.add_config(
251
- DuckDBConfig(
252
- extensions=[{"name": "vss"}, {"name": "http_client"}],
253
- on_connection_create=lambda connection: connection.execute(f"""
324
+ db_manager = SQLSpec()
325
+ config = DuckDBConfig(
326
+ pool_config={"database": ":memory:"},
327
+ driver_features={
328
+ "extensions": [{"name": "vss"}, {"name": "http_client"}],
329
+ "on_connection_create": lambda connection: connection.execute(f"""
254
330
  CREATE IF NOT EXISTS MACRO generate_embedding(q) AS (
255
331
  WITH __request AS (
256
332
  SELECT http_post(
@@ -269,16 +345,77 @@ etl_config = sql.add_config(
269
345
  FROM __request,
270
346
  );
271
347
  """),
272
- )
348
+ },
273
349
  )
274
- with sql.provide_session(etl_config) as session:
350
+ db_manager.add_config(config)
351
+
352
+ with db_manager.provide_session(config) as session:
275
353
  result = session.execute("SELECT generate_embedding('example text')")
276
354
  print(result.get_first()) # result is a dictionary when `schema_type` is omitted.
277
355
  ```
278
356
 
357
+ </details>
358
+
359
+ ### SQL File Loading
360
+
361
+ SQLSpec can load and manage SQL queries from files using aiosql-style named queries:
362
+
363
+ ```python
364
+ from sqlspec import SQLSpec
365
+ from sqlspec.loader import SQLFileLoader
366
+ from sqlspec.adapters.sqlite import SqliteConfig
367
+
368
+ # Initialize with SQL file loader
369
+ db_manager = SQLSpec(loader=SQLFileLoader())
370
+ config = SqliteConfig(pool_config={"database": ":memory:"})
371
+ db_manager.add_config(config)
372
+
373
+ # Load SQL files from directory
374
+ db_manager.load_sql_files("./sql")
375
+
376
+ # SQL file: ./sql/users.sql
377
+ # -- name: get_user
378
+ # SELECT * FROM users WHERE id = ?
379
+ #
380
+ # -- name: create_user
381
+ # INSERT INTO users (name, email) VALUES (?, ?)
382
+
383
+ with db_manager.provide_session(config) as session:
384
+ # Use named queries from files
385
+ user = session.execute(db_manager.get_sql("get_user"), 1)
386
+ session.execute(db_manager.get_sql("create_user"), "Alice", "alice@example.com")
387
+ ```
388
+
389
+ ### Database Migrations
390
+
391
+ SQLSpec includes a built-in migration system for managing schema changes. After configuring your database with migration settings, use the CLI commands:
392
+
393
+ ```bash
394
+ # Initialize migration directory
395
+ sqlspec db init migrations
396
+
397
+ # Generate new migration file
398
+ sqlspec db make-migrations "Add user table"
399
+
400
+ # Apply all pending migrations
401
+ sqlspec db upgrade
402
+
403
+ # Show current migration status
404
+ sqlspec db show-current-revision
405
+ ```
406
+
407
+ For Litestar applications, replace `sqlspec` with your application command:
408
+
409
+ ```bash
410
+ # Using Litestar CLI integration
411
+ litestar db make-migrations "Add user table"
412
+ litestar db upgrade
413
+ litestar db show-current-revision
414
+ ```
415
+
279
416
  ### Basic Litestar Integration
280
417
 
281
- In this example we are going to demonstrate how to create a basic configuration that integrates into Litestar.
418
+ In this example we demonstrate how to create a basic configuration that integrates into Litestar:
282
419
 
283
420
  ```py
284
421
  # /// script
@@ -301,7 +438,7 @@ async def simple_sqlite(db_session: AiosqliteDriver) -> dict[str, str]:
301
438
 
302
439
  sqlspec = SQLSpec(
303
440
  config=DatabaseConfig(
304
- config=AiosqliteConfig(),
441
+ config=AiosqliteConfig(pool_config={"database": ":memory:"}), # built in local pooling
305
442
  commit_mode="autocommit"
306
443
  )
307
444
  )
@@ -320,6 +457,41 @@ The primary goal at this stage is to establish a **native connectivity interface
320
457
 
321
458
  This list is not final. If you have a driver you'd like to see added, please open an issue or submit a PR!
322
459
 
460
+ ### Configuration Examples
461
+
462
+ Each adapter uses a consistent configuration pattern with `pool_config` for connection parameters:
463
+
464
+ ```python
465
+ # SQLite
466
+ SqliteConfig(pool_config={"database": "/path/to/database.db"})
467
+ AiosqliteConfig(pool_config={"database": "/path/to/database.db"}) # Async
468
+ AdbcConfig(connection_config={"uri": "sqlite:///path/to/database.db"}) # ADBC
469
+
470
+ # PostgreSQL (multiple drivers available)
471
+ PsycopgSyncConfig(pool_config={"host": "localhost", "database": "mydb", "user": "user", "password": "pass"})
472
+ PsycopgAsyncConfig(pool_config={"host": "localhost", "database": "mydb", "user": "user", "password": "pass"}) # Async
473
+ AsyncpgConfig(pool_config={"host": "localhost", "database": "mydb", "user": "user", "password": "pass"})
474
+ PsqlpyConfig(pool_config={"dsn": "postgresql://user:pass@localhost/mydb"})
475
+ AdbcConfig(connection_config={"uri": "postgresql://user:pass@localhost/mydb"}) # ADBC
476
+
477
+ # DuckDB
478
+ DuckDBConfig(pool_config={"database": ":memory:"}) # or file path
479
+ AdbcConfig(connection_config={"uri": "duckdb:///path/to/database.duckdb"}) # ADBC
480
+
481
+ # MySQL
482
+ AsyncmyConfig(pool_config={"host": "localhost", "database": "mydb", "user": "user", "password": "pass"}) # Async
483
+
484
+ # Oracle
485
+ OracleSyncConfig(pool_config={"host": "localhost", "service_name": "XEPDB1", "user": "user", "password": "pass"})
486
+ OracleAsyncConfig(pool_config={"host": "localhost", "service_name": "XEPDB1", "user": "user", "password": "pass"}) # Async
487
+
488
+ # BigQuery
489
+ BigQueryConfig(pool_config={"project": "my-project", "dataset": "my_dataset"})
490
+ AdbcConfig(connection_config={"driver_name": "adbc_driver_bigquery", "project_id": "my-project", "dataset_id": "my_dataset"}) # ADBC
491
+ ```
492
+
493
+ ### Supported Drivers
494
+
323
495
  | Driver | Database | Mode | Status |
324
496
  | :----------------------------------------------------------------------------------------------------------- | :--------- | :------ | :--------- |
325
497
  | [`adbc`](https://arrow.apache.org/adbc/) | Postgres | Sync | ✅ |
@@ -342,21 +514,35 @@ This list is not final. If you have a driver you'd like to see added, please ope
342
514
  | [`asyncmy`](https://github.com/long2ice/asyncmy) | MySQL | Async | ✅ |
343
515
  | [`snowflake`](https://docs.snowflake.com) | Snowflake | Sync | 🗓️ |
344
516
 
345
- ## Proposed Project Structure
517
+ ## Project Structure
346
518
 
347
519
  - `sqlspec/`:
348
- - `adapters/`: Contains all database drivers and associated configuration.
349
- - `extensions/`:
350
- - `litestar/`: Litestar framework integration ✅
351
- - `fastapi/`: Future home of `fastapi` integration.
352
- - `flask/`: Future home of `flask` integration.
353
- - `*/`: Future home of your favorite framework integration
354
- - `base.py`: Contains base protocols for database configurations.
355
- - `statement/`: Contains the SQL statement system with builders, validation, and transformation.
356
- - `storage/`: Contains unified storage operations for data import/export.
357
- - `utils/`: Contains utility functions used throughout the project.
358
- - `exceptions.py`: Contains custom exceptions for SQLSpec.
359
- - `typing.py`: Contains type hints, type guards and several facades for optional libraries that are not required for the core functionality of SQLSpec.
520
+ - `adapters/`: Database-specific drivers and configuration classes for all supported databases
521
+ - `extensions/`: Framework integrations and external library adapters
522
+ - `litestar/`: Litestar web framework integration with dependency injection
523
+ - `aiosql/`: Integration with aiosql for SQL file loading ✅
524
+ - Future integrations: `fastapi/`, `flask/`, etc.
525
+ - `builder/`: Fluent SQL query builder with method chaining and type safety
526
+ - `mixins/`: Composable query building operations (WHERE, JOIN, ORDER BY, etc.)
527
+ - `core/`: Core query processing infrastructure
528
+ - `statement.py`: SQL statement wrapper with metadata and type information
529
+ - `parameters.py`: Parameter style conversion and validation
530
+ - `result.py`: Result set handling and type mapping
531
+ - `compiler.py`: SQL compilation and validation using SQLGlot
532
+ - `cache.py`: Statement caching for performance optimization
533
+ - `driver/`: Base driver system with sync/async support and transaction management
534
+ - `mixins/`: Shared driver capabilities (result processing, SQL translation)
535
+ - `migrations/`: Database migration system with CLI commands
536
+ - `storage/`: Unified data import/export operations with multiple backends
537
+ - `backends/`: Storage backend implementations (fsspec, obstore)
538
+ - `utils/`: Utility functions, type guards, and helper tools
539
+ - `base.py`: Main SQLSpec registry and configuration manager
540
+ - `loader.py`: SQL file loading system for `.sql` files
541
+ - `cli.py`: Command-line interface for migrations and database operations
542
+ - `config.py`: Base configuration classes and protocols
543
+ - `protocols.py`: Type protocols for runtime type checking
544
+ - `exceptions.py`: Custom exception hierarchy for SQLSpec
545
+ - `typing.py`: Type definitions, guards, and optional dependency facades
360
546
 
361
547
  ## Get Involved
362
548