sqlspec 0.11.1__tar.gz → 0.16.2__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.
- {sqlspec-0.11.1 → sqlspec-0.16.2}/.gitignore +30 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/.pre-commit-config.yaml +3 -3
- {sqlspec-0.11.1 → sqlspec-0.16.2}/Makefile +73 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/PKG-INFO +102 -26
- {sqlspec-0.11.1 → sqlspec-0.16.2}/README.md +78 -23
- {sqlspec-0.11.1 → sqlspec-0.16.2}/pyproject.toml +140 -17
- sqlspec-0.16.2/sqlspec/__init__.py +92 -0
- sqlspec-0.16.2/sqlspec/__main__.py +12 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/__metadata__.py +1 -3
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/_serialization.py +4 -12
- sqlspec-0.16.2/sqlspec/_sql.py +1782 -0
- sqlspec-0.16.2/sqlspec/_typing.py +680 -0
- sqlspec-0.16.2/sqlspec/adapters/adbc/__init__.py +5 -0
- sqlspec-0.16.2/sqlspec/adapters/adbc/_types.py +12 -0
- sqlspec-0.16.2/sqlspec/adapters/adbc/config.py +361 -0
- sqlspec-0.16.2/sqlspec/adapters/adbc/driver.py +512 -0
- sqlspec-0.16.2/sqlspec/adapters/aiosqlite/__init__.py +19 -0
- sqlspec-0.16.2/sqlspec/adapters/aiosqlite/_types.py +13 -0
- sqlspec-0.16.2/sqlspec/adapters/aiosqlite/config.py +253 -0
- sqlspec-0.16.2/sqlspec/adapters/aiosqlite/driver.py +248 -0
- sqlspec-0.16.2/sqlspec/adapters/asyncmy/__init__.py +19 -0
- sqlspec-0.16.2/sqlspec/adapters/asyncmy/_types.py +12 -0
- sqlspec-0.16.2/sqlspec/adapters/asyncmy/config.py +180 -0
- sqlspec-0.16.2/sqlspec/adapters/asyncmy/driver.py +274 -0
- sqlspec-0.16.2/sqlspec/adapters/asyncpg/__init__.py +21 -0
- sqlspec-0.16.2/sqlspec/adapters/asyncpg/_types.py +17 -0
- sqlspec-0.16.2/sqlspec/adapters/asyncpg/config.py +229 -0
- sqlspec-0.16.2/sqlspec/adapters/asyncpg/driver.py +344 -0
- sqlspec-0.16.2/sqlspec/adapters/bigquery/__init__.py +18 -0
- sqlspec-0.16.2/sqlspec/adapters/bigquery/_types.py +12 -0
- sqlspec-0.16.2/sqlspec/adapters/bigquery/config.py +298 -0
- sqlspec-0.16.2/sqlspec/adapters/bigquery/driver.py +558 -0
- sqlspec-0.16.2/sqlspec/adapters/duckdb/__init__.py +22 -0
- sqlspec-0.16.2/sqlspec/adapters/duckdb/_types.py +12 -0
- sqlspec-0.16.2/sqlspec/adapters/duckdb/config.py +504 -0
- sqlspec-0.16.2/sqlspec/adapters/duckdb/driver.py +368 -0
- sqlspec-0.16.2/sqlspec/adapters/oracledb/__init__.py +32 -0
- sqlspec-0.16.2/sqlspec/adapters/oracledb/_types.py +14 -0
- sqlspec-0.16.2/sqlspec/adapters/oracledb/config.py +317 -0
- sqlspec-0.16.2/sqlspec/adapters/oracledb/driver.py +538 -0
- sqlspec-0.16.2/sqlspec/adapters/psqlpy/__init__.py +16 -0
- sqlspec-0.16.2/sqlspec/adapters/psqlpy/_types.py +11 -0
- sqlspec-0.16.2/sqlspec/adapters/psqlpy/config.py +214 -0
- sqlspec-0.16.2/sqlspec/adapters/psqlpy/driver.py +530 -0
- sqlspec-0.16.2/sqlspec/adapters/psycopg/__init__.py +32 -0
- sqlspec-0.16.2/sqlspec/adapters/psycopg/_types.py +17 -0
- sqlspec-0.16.2/sqlspec/adapters/psycopg/config.py +426 -0
- sqlspec-0.16.2/sqlspec/adapters/psycopg/driver.py +796 -0
- sqlspec-0.16.2/sqlspec/adapters/sqlite/__init__.py +15 -0
- sqlspec-0.16.2/sqlspec/adapters/sqlite/_types.py +11 -0
- sqlspec-0.16.2/sqlspec/adapters/sqlite/config.py +240 -0
- sqlspec-0.16.2/sqlspec/adapters/sqlite/driver.py +294 -0
- sqlspec-0.16.2/sqlspec/base.py +571 -0
- sqlspec-0.16.2/sqlspec/builder/__init__.py +62 -0
- sqlspec-0.16.2/sqlspec/builder/_base.py +473 -0
- sqlspec-0.16.2/sqlspec/builder/_column.py +320 -0
- sqlspec-0.16.2/sqlspec/builder/_ddl.py +1346 -0
- sqlspec-0.16.2/sqlspec/builder/_ddl_utils.py +103 -0
- sqlspec-0.16.2/sqlspec/builder/_delete.py +76 -0
- sqlspec-0.16.2/sqlspec/builder/_insert.py +421 -0
- sqlspec-0.16.2/sqlspec/builder/_merge.py +71 -0
- sqlspec-0.16.2/sqlspec/builder/_parsing_utils.py +164 -0
- sqlspec-0.16.2/sqlspec/builder/_select.py +170 -0
- sqlspec-0.16.2/sqlspec/builder/_update.py +188 -0
- sqlspec-0.16.2/sqlspec/builder/mixins/__init__.py +55 -0
- sqlspec-0.16.2/sqlspec/builder/mixins/_cte_and_set_ops.py +222 -0
- sqlspec-0.16.2/sqlspec/builder/mixins/_delete_operations.py +41 -0
- sqlspec-0.16.2/sqlspec/builder/mixins/_insert_operations.py +244 -0
- sqlspec-0.16.2/sqlspec/builder/mixins/_join_operations.py +149 -0
- sqlspec-0.16.2/sqlspec/builder/mixins/_merge_operations.py +562 -0
- sqlspec-0.16.2/sqlspec/builder/mixins/_order_limit_operations.py +135 -0
- sqlspec-0.16.2/sqlspec/builder/mixins/_pivot_operations.py +153 -0
- sqlspec-0.16.2/sqlspec/builder/mixins/_select_operations.py +604 -0
- sqlspec-0.16.2/sqlspec/builder/mixins/_update_operations.py +202 -0
- sqlspec-0.16.2/sqlspec/builder/mixins/_where_clause.py +644 -0
- sqlspec-0.16.2/sqlspec/cli.py +247 -0
- sqlspec-0.16.2/sqlspec/config.py +395 -0
- sqlspec-0.16.2/sqlspec/core/__init__.py +63 -0
- sqlspec-0.16.2/sqlspec/core/cache.py +871 -0
- sqlspec-0.16.2/sqlspec/core/compiler.py +417 -0
- sqlspec-0.16.2/sqlspec/core/filters.py +830 -0
- sqlspec-0.16.2/sqlspec/core/hashing.py +310 -0
- sqlspec-0.16.2/sqlspec/core/parameters.py +1237 -0
- sqlspec-0.16.2/sqlspec/core/result.py +677 -0
- sqlspec-0.16.2/sqlspec/core/splitter.py +819 -0
- sqlspec-0.16.2/sqlspec/core/statement.py +676 -0
- sqlspec-0.16.2/sqlspec/driver/__init__.py +19 -0
- sqlspec-0.16.2/sqlspec/driver/_async.py +502 -0
- sqlspec-0.16.2/sqlspec/driver/_common.py +631 -0
- sqlspec-0.16.2/sqlspec/driver/_sync.py +503 -0
- sqlspec-0.16.2/sqlspec/driver/mixins/__init__.py +6 -0
- sqlspec-0.16.2/sqlspec/driver/mixins/_result_tools.py +193 -0
- sqlspec-0.16.2/sqlspec/driver/mixins/_sql_translator.py +86 -0
- sqlspec-0.16.2/sqlspec/exceptions.py +193 -0
- sqlspec-0.16.2/sqlspec/extensions/aiosql/__init__.py +10 -0
- sqlspec-0.16.2/sqlspec/extensions/aiosql/adapter.py +461 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/extensions/litestar/__init__.py +2 -6
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/extensions/litestar/_utils.py +1 -5
- sqlspec-0.16.2/sqlspec/extensions/litestar/cli.py +48 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/extensions/litestar/config.py +5 -7
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/extensions/litestar/handlers.py +26 -37
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/extensions/litestar/plugin.py +39 -39
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/extensions/litestar/providers.py +53 -120
- sqlspec-0.16.2/sqlspec/loader.py +760 -0
- sqlspec-0.16.2/sqlspec/migrations/__init__.py +35 -0
- sqlspec-0.16.2/sqlspec/migrations/base.py +414 -0
- sqlspec-0.16.2/sqlspec/migrations/commands.py +443 -0
- sqlspec-0.16.2/sqlspec/migrations/loaders.py +402 -0
- sqlspec-0.16.2/sqlspec/migrations/runner.py +213 -0
- sqlspec-0.16.2/sqlspec/migrations/tracker.py +140 -0
- sqlspec-0.16.2/sqlspec/migrations/utils.py +129 -0
- sqlspec-0.16.2/sqlspec/protocols.py +407 -0
- sqlspec-0.16.2/sqlspec/storage/__init__.py +23 -0
- sqlspec-0.16.2/sqlspec/storage/backends/base.py +163 -0
- sqlspec-0.16.2/sqlspec/storage/backends/fsspec.py +386 -0
- sqlspec-0.16.2/sqlspec/storage/backends/obstore.py +459 -0
- sqlspec-0.16.2/sqlspec/storage/capabilities.py +102 -0
- sqlspec-0.16.2/sqlspec/storage/registry.py +239 -0
- sqlspec-0.16.2/sqlspec/typing.py +299 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/utils/__init__.py +2 -2
- sqlspec-0.16.2/sqlspec/utils/correlation.py +150 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/utils/deprecation.py +9 -12
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/utils/fixtures.py +12 -17
- sqlspec-0.16.2/sqlspec/utils/logging.py +127 -0
- sqlspec-0.16.2/sqlspec/utils/module_loader.py +89 -0
- sqlspec-0.16.2/sqlspec/utils/serializers.py +4 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/utils/singleton.py +6 -9
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/utils/sync_tools.py +32 -69
- sqlspec-0.16.2/sqlspec/utils/text.py +96 -0
- sqlspec-0.16.2/sqlspec/utils/type_guards.py +1139 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/tests/conftest.py +11 -0
- sqlspec-0.16.2/tests/fixtures/ddls-mysql-collection.sql +257 -0
- sqlspec-0.16.2/tests/fixtures/ddls-postgres-collection.sql +913 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/tests/fixtures/example_usage.py +16 -16
- sqlspec-0.16.2/tests/fixtures/init.sql +25 -0
- sqlspec-0.16.2/tests/fixtures/mysql/collection-config.sql +570 -0
- sqlspec-0.16.2/tests/fixtures/mysql/collection-data_types.sql +42 -0
- sqlspec-0.16.2/tests/fixtures/mysql/collection-database_details.sql +182 -0
- sqlspec-0.16.2/tests/fixtures/mysql/collection-engines.sql +34 -0
- sqlspec-0.16.2/tests/fixtures/mysql/collection-hostname.sql +17 -0
- sqlspec-0.16.2/tests/fixtures/mysql/collection-plugins.sql +44 -0
- sqlspec-0.16.2/tests/fixtures/mysql/collection-process_list.sql +38 -0
- sqlspec-0.16.2/tests/fixtures/mysql/collection-resource-groups.sql +50 -0
- sqlspec-0.16.2/tests/fixtures/mysql/collection-schema_objects.sql +197 -0
- sqlspec-0.16.2/tests/fixtures/mysql/collection-table_details.sql +134 -0
- sqlspec-0.16.2/tests/fixtures/mysql/collection-users.sql +52 -0
- sqlspec-0.16.2/tests/fixtures/mysql/init.sql +39 -0
- sqlspec-0.16.2/tests/fixtures/oracle.ddl.sql +206 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-applications.sql +26 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-aws_extension_dependency.sql +406 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-aws_oracle_exists.sql +25 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-bg_writer_stats.sql +63 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-calculated_metrics.sql +245 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-data_types.sql +72 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-database_details.sql +386 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-extensions.sql +41 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-index_details.sql +75 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-pglogical-details.sql +28 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-privileges.sql +152 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-replication_slots.sql +131 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-replication_stats.sql +63 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-schema_details.sql +77 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-schema_objects.sql +205 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-settings.sql +56 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-source_details.sql +63 -0
- sqlspec-0.16.2/tests/fixtures/postgres/collection-table_details.sql +496 -0
- sqlspec-0.16.2/tests/fixtures/postgres/extended-collection-all-databases.sql +36 -0
- sqlspec-0.16.2/tests/fixtures/postgres/init.sql +24 -0
- sqlspec-0.16.2/tests/fixtures/readiness-check.sql +35 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/tests/fixtures/sql_utils.py +5 -5
- sqlspec-0.16.2/tests/integration/__init__.py +1 -0
- sqlspec-0.16.2/tests/integration/conftest.py +39 -0
- sqlspec-0.16.2/tests/integration/test_adapters/__init__.py +1 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_adbc/__init__.py +1 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/tests/integration/test_adapters/test_adbc/conftest.py +7 -6
- sqlspec-0.16.2/tests/integration/test_adapters/test_adbc/test_adbc_arrow_features.py +404 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_adbc/test_adbc_backends.py +254 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_adbc/test_adbc_connection.py +190 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_adbc/test_adbc_driver.py +424 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_adbc/test_adbc_edge_cases.py +537 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_adbc/test_adbc_results.py +398 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_aiosqlite/__init__.py +1 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_aiosqlite/conftest.py +61 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_aiosqlite/test_connection.py +301 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_aiosqlite/test_driver.py +487 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_aiosqlite/test_pooling.py +212 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_asyncmy/conftest.py +65 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_asyncmy/test_asyncmy_features.py +335 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_asyncmy/test_config.py +144 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_asyncmy/test_driver.py +429 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_asyncmy/test_parameter_styles.py +372 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_asyncpg/__init__.py +1 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_asyncpg/conftest.py +55 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/tests/integration/test_adapters/test_asyncpg/test_connection.py +12 -9
- sqlspec-0.16.2/tests/integration/test_adapters/test_asyncpg/test_driver.py +711 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_asyncpg/test_execute_many.py +329 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_asyncpg/test_parameter_styles.py +419 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_bigquery/__init__.py +1 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_bigquery/conftest.py +75 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_bigquery/test_bigquery_features.py +363 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_bigquery/test_config.py +151 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_bigquery/test_connection.py +17 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_bigquery/test_driver.py +506 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_bigquery/test_parameter_styles.py +193 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_duckdb/test_connection.py +377 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_duckdb/test_driver.py +561 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_duckdb/test_execute_many.py +314 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_duckdb/test_mixed_parameter_styles.py +164 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_duckdb/test_parameter_styles.py +520 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_duckdb/test_pooling.py +156 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_duckdb/utils.py +40 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_oracledb/conftest.py +52 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_oracledb/test_connection.py +108 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_oracledb/test_driver_async.py +319 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_oracledb/test_driver_sync.py +314 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_oracledb/test_execute_many.py +365 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_oracledb/test_oracle_features.py +404 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_oracledb/test_parameter_styles.py +347 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_psqlpy/__init__.py +1 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_psqlpy/conftest.py +47 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_psqlpy/test_connection.py +137 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_psqlpy/test_driver.py +468 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_psqlpy/test_parameter_styles.py +242 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_psqlpy/test_psqlpy_features.py +250 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_psycopg/__init__.py +3 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_psycopg/conftest.py +53 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_psycopg/test_async_copy.py +173 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_psycopg/test_connection.py +90 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_psycopg/test_driver.py +624 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_psycopg/test_execute_many.py +364 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_psycopg/test_parameter_styles.py +538 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_sqlite/__init__.py +1 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_sqlite/conftest.py +121 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_sqlite/test_driver.py +527 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_sqlite/test_parameter_styles.py +229 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_sqlite/test_pooling.py +323 -0
- sqlspec-0.16.2/tests/integration/test_adapters/test_sqlite/test_query_mixin.py +221 -0
- sqlspec-0.16.2/tests/integration/test_loader/__init__.py +5 -0
- sqlspec-0.16.2/tests/integration/test_loader/test_file_system_loading.py +752 -0
- sqlspec-0.16.2/tests/integration/test_migrations/__init__.py +5 -0
- sqlspec-0.16.2/tests/integration/test_migrations/test_migration_execution.py +660 -0
- sqlspec-0.16.2/tests/unit/conftest.py +1017 -0
- sqlspec-0.16.2/tests/unit/test_adapters/__init__.py +3 -0
- sqlspec-0.16.2/tests/unit/test_adapters/conftest.py +446 -0
- sqlspec-0.16.2/tests/unit/test_adapters/test_adapter_implementations.py +477 -0
- sqlspec-0.16.2/tests/unit/test_adapters/test_async_adapters.py +615 -0
- sqlspec-0.16.2/tests/unit/test_adapters/test_sync_adapters.py +490 -0
- sqlspec-0.16.2/tests/unit/test_base/__init__.py +1 -0
- sqlspec-0.16.2/tests/unit/test_base/test_sqlspec_class.py +669 -0
- sqlspec-0.16.2/tests/unit/test_builder/__init__.py +1 -0
- sqlspec-0.16.2/tests/unit/test_builder/test_insert_builder.py +321 -0
- sqlspec-0.16.2/tests/unit/test_builder/test_parameter_naming.py +392 -0
- sqlspec-0.16.2/tests/unit/test_builder_parameter_naming.py +213 -0
- sqlspec-0.16.2/tests/unit/test_core/test_cache.py +1031 -0
- sqlspec-0.16.2/tests/unit/test_core/test_compiler.py +861 -0
- sqlspec-0.16.2/tests/unit/test_core/test_filters.py +354 -0
- sqlspec-0.16.2/tests/unit/test_core/test_hashing.py +577 -0
- sqlspec-0.16.2/tests/unit/test_core/test_parameters.py +1181 -0
- sqlspec-0.16.2/tests/unit/test_core/test_result.py +151 -0
- sqlspec-0.16.2/tests/unit/test_core/test_statement.py +1146 -0
- sqlspec-0.16.2/tests/unit/test_loader/__init__.py +5 -0
- sqlspec-0.16.2/tests/unit/test_loader/test_cache_integration.py +682 -0
- sqlspec-0.16.2/tests/unit/test_loader/test_loading_patterns.py +888 -0
- sqlspec-0.16.2/tests/unit/test_loader/test_sql_file_loader.py +962 -0
- sqlspec-0.16.2/tests/unit/test_migrations/__init__.py +10 -0
- sqlspec-0.16.2/tests/unit/test_migrations/test_migration.py +763 -0
- sqlspec-0.16.2/tests/unit/test_migrations/test_migration_execution.py +671 -0
- sqlspec-0.16.2/tests/unit/test_migrations/test_migration_runner.py +587 -0
- sqlspec-0.16.2/tests/unit/test_sql_factory.py +1523 -0
- sqlspec-0.16.2/tests/unit/test_utils/__init__.py +1 -0
- sqlspec-0.16.2/tests/unit/test_utils/test_correlation.py +508 -0
- sqlspec-0.16.2/tests/unit/test_utils/test_deprecation.py +151 -0
- sqlspec-0.16.2/tests/unit/test_utils/test_fixtures.py +74 -0
- sqlspec-0.16.2/tests/unit/test_utils/test_logging.py +702 -0
- sqlspec-0.16.2/tests/unit/test_utils/test_module_loader.py +100 -0
- sqlspec-0.16.2/tests/unit/test_utils/test_serializers.py +487 -0
- sqlspec-0.16.2/tests/unit/test_utils/test_singleton.py +98 -0
- sqlspec-0.16.2/tests/unit/test_utils/test_sync_tools.py +400 -0
- sqlspec-0.16.2/tests/unit/test_utils/test_text.py +316 -0
- sqlspec-0.16.2/tests/unit/test_utils/test_type_guards.py +933 -0
- sqlspec-0.16.2/tools/local-infra.sh +686 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/tools/sphinx_ext/changelog.py +2 -7
- sqlspec-0.16.2/tools/sphinx_ext/missing_references.py +382 -0
- sqlspec-0.16.2/uv.lock +6084 -0
- sqlspec-0.11.1/sqlspec/__init__.py +0 -16
- sqlspec-0.11.1/sqlspec/_typing.py +0 -242
- sqlspec-0.11.1/sqlspec/adapters/adbc/__init__.py +0 -8
- sqlspec-0.11.1/sqlspec/adapters/adbc/config.py +0 -207
- sqlspec-0.11.1/sqlspec/adapters/adbc/driver.py +0 -679
- sqlspec-0.11.1/sqlspec/adapters/aiosqlite/__init__.py +0 -8
- sqlspec-0.11.1/sqlspec/adapters/aiosqlite/config.py +0 -102
- sqlspec-0.11.1/sqlspec/adapters/aiosqlite/driver.py +0 -456
- sqlspec-0.11.1/sqlspec/adapters/asyncmy/__init__.py +0 -9
- sqlspec-0.11.1/sqlspec/adapters/asyncmy/config.py +0 -241
- sqlspec-0.11.1/sqlspec/adapters/asyncmy/driver.py +0 -462
- sqlspec-0.11.1/sqlspec/adapters/asyncpg/__init__.py +0 -9
- sqlspec-0.11.1/sqlspec/adapters/asyncpg/config.py +0 -221
- sqlspec-0.11.1/sqlspec/adapters/asyncpg/driver.py +0 -531
- sqlspec-0.11.1/sqlspec/adapters/bigquery/__init__.py +0 -4
- sqlspec-0.11.1/sqlspec/adapters/bigquery/config/__init__.py +0 -3
- sqlspec-0.11.1/sqlspec/adapters/bigquery/config/_common.py +0 -40
- sqlspec-0.11.1/sqlspec/adapters/bigquery/config/_sync.py +0 -87
- sqlspec-0.11.1/sqlspec/adapters/bigquery/driver.py +0 -621
- sqlspec-0.11.1/sqlspec/adapters/duckdb/__init__.py +0 -8
- sqlspec-0.11.1/sqlspec/adapters/duckdb/config.py +0 -379
- sqlspec-0.11.1/sqlspec/adapters/duckdb/driver.py +0 -425
- sqlspec-0.11.1/sqlspec/adapters/oracledb/__init__.py +0 -23
- sqlspec-0.11.1/sqlspec/adapters/oracledb/config/__init__.py +0 -9
- sqlspec-0.11.1/sqlspec/adapters/oracledb/config/_asyncio.py +0 -186
- sqlspec-0.11.1/sqlspec/adapters/oracledb/config/_common.py +0 -131
- sqlspec-0.11.1/sqlspec/adapters/oracledb/config/_sync.py +0 -186
- sqlspec-0.11.1/sqlspec/adapters/oracledb/driver.py +0 -954
- sqlspec-0.11.1/sqlspec/adapters/psqlpy/__init__.py +0 -9
- sqlspec-0.11.1/sqlspec/adapters/psqlpy/config.py +0 -250
- sqlspec-0.11.1/sqlspec/adapters/psqlpy/driver.py +0 -550
- sqlspec-0.11.1/sqlspec/adapters/psycopg/__init__.py +0 -23
- sqlspec-0.11.1/sqlspec/adapters/psycopg/config/__init__.py +0 -19
- sqlspec-0.11.1/sqlspec/adapters/psycopg/config/_async.py +0 -169
- sqlspec-0.11.1/sqlspec/adapters/psycopg/config/_common.py +0 -56
- sqlspec-0.11.1/sqlspec/adapters/psycopg/config/_sync.py +0 -168
- sqlspec-0.11.1/sqlspec/adapters/psycopg/driver.py +0 -749
- sqlspec-0.11.1/sqlspec/adapters/sqlite/__init__.py +0 -8
- sqlspec-0.11.1/sqlspec/adapters/sqlite/config.py +0 -109
- sqlspec-0.11.1/sqlspec/adapters/sqlite/driver.py +0 -426
- sqlspec-0.11.1/sqlspec/base.py +0 -1039
- sqlspec-0.11.1/sqlspec/exceptions.py +0 -140
- sqlspec-0.11.1/sqlspec/filters.py +0 -331
- sqlspec-0.11.1/sqlspec/mixins.py +0 -305
- sqlspec-0.11.1/sqlspec/statement.py +0 -378
- sqlspec-0.11.1/sqlspec/typing.py +0 -585
- sqlspec-0.11.1/sqlspec/utils/module_loader.py +0 -92
- sqlspec-0.11.1/sqlspec/utils/text.py +0 -108
- sqlspec-0.11.1/tests/integration/__init__.py +0 -3
- sqlspec-0.11.1/tests/integration/test_adapters/__init__.py +0 -1
- sqlspec-0.11.1/tests/integration/test_adapters/test_adbc/__init__.py +0 -5
- sqlspec-0.11.1/tests/integration/test_adapters/test_adbc/test_connection.py +0 -31
- sqlspec-0.11.1/tests/integration/test_adapters/test_adbc/test_driver_bigquery.py +0 -227
- sqlspec-0.11.1/tests/integration/test_adapters/test_adbc/test_driver_duckdb.py +0 -444
- sqlspec-0.11.1/tests/integration/test_adapters/test_adbc/test_driver_postgres.py +0 -201
- sqlspec-0.11.1/tests/integration/test_adapters/test_adbc/test_driver_sqlite.py +0 -302
- sqlspec-0.11.1/tests/integration/test_adapters/test_aiosqlite/__init__.py +0 -5
- sqlspec-0.11.1/tests/integration/test_adapters/test_aiosqlite/test_connection.py +0 -28
- sqlspec-0.11.1/tests/integration/test_adapters/test_aiosqlite/test_driver.py +0 -168
- sqlspec-0.11.1/tests/integration/test_adapters/test_asyncmy/test_connection.py +0 -54
- sqlspec-0.11.1/tests/integration/test_adapters/test_asyncmy/test_driver.py +0 -218
- sqlspec-0.11.1/tests/integration/test_adapters/test_asyncpg/test_driver.py +0 -395
- sqlspec-0.11.1/tests/integration/test_adapters/test_bigquery/conftest.py +0 -31
- sqlspec-0.11.1/tests/integration/test_adapters/test_bigquery/test_connection.py +0 -14
- sqlspec-0.11.1/tests/integration/test_adapters/test_bigquery/test_driver.py +0 -288
- sqlspec-0.11.1/tests/integration/test_adapters/test_duckdb/test_connection.py +0 -28
- sqlspec-0.11.1/tests/integration/test_adapters/test_duckdb/test_driver.py +0 -169
- sqlspec-0.11.1/tests/integration/test_adapters/test_oracledb/test_connection.py +0 -106
- sqlspec-0.11.1/tests/integration/test_adapters/test_oracledb/test_driver_async.py +0 -201
- sqlspec-0.11.1/tests/integration/test_adapters/test_oracledb/test_driver_sync.py +0 -197
- sqlspec-0.11.1/tests/integration/test_adapters/test_psqlpy/__init__.py +0 -0
- sqlspec-0.11.1/tests/integration/test_adapters/test_psqlpy/test_connection.py +0 -66
- sqlspec-0.11.1/tests/integration/test_adapters/test_psqlpy/test_driver.py +0 -315
- sqlspec-0.11.1/tests/integration/test_adapters/test_psycopg/__init__.py +0 -5
- sqlspec-0.11.1/tests/integration/test_adapters/test_psycopg/test_connection.py +0 -81
- sqlspec-0.11.1/tests/integration/test_adapters/test_psycopg/test_driver.py +0 -408
- sqlspec-0.11.1/tests/integration/test_adapters/test_sqlite/__init__.py +0 -5
- sqlspec-0.11.1/tests/integration/test_adapters/test_sqlite/test_connection.py +0 -27
- sqlspec-0.11.1/tests/integration/test_adapters/test_sqlite/test_driver.py +0 -178
- sqlspec-0.11.1/tests/unit/__init__.py +0 -0
- sqlspec-0.11.1/tests/unit/test_adapters/__init__.py +0 -0
- sqlspec-0.11.1/tests/unit/test_adapters/test_adbc/__init__.py +0 -1
- sqlspec-0.11.1/tests/unit/test_adapters/test_adbc/test_config.py +0 -91
- sqlspec-0.11.1/tests/unit/test_adapters/test_aiosqlite/__init__.py +0 -1
- sqlspec-0.11.1/tests/unit/test_adapters/test_aiosqlite/test_config.py +0 -107
- sqlspec-0.11.1/tests/unit/test_adapters/test_asyncmy/__init__.py +0 -1
- sqlspec-0.11.1/tests/unit/test_adapters/test_asyncmy/test_config.py +0 -152
- sqlspec-0.11.1/tests/unit/test_adapters/test_asyncpg/__init__.py +0 -1
- sqlspec-0.11.1/tests/unit/test_adapters/test_asyncpg/test_config.py +0 -153
- sqlspec-0.11.1/tests/unit/test_adapters/test_duckdb/__init__.py +0 -0
- sqlspec-0.11.1/tests/unit/test_adapters/test_duckdb/test_config.py +0 -137
- sqlspec-0.11.1/tests/unit/test_adapters/test_oracledb/__init__.py +0 -1
- sqlspec-0.11.1/tests/unit/test_adapters/test_oracledb/test_async_config.py +0 -135
- sqlspec-0.11.1/tests/unit/test_adapters/test_oracledb/test_sync_config.py +0 -129
- sqlspec-0.11.1/tests/unit/test_adapters/test_psycopg/__init__.py +0 -1
- sqlspec-0.11.1/tests/unit/test_adapters/test_psycopg/test_async_config.py +0 -179
- sqlspec-0.11.1/tests/unit/test_adapters/test_psycopg/test_sync_config.py +0 -160
- sqlspec-0.11.1/tests/unit/test_adapters/test_sqlite/__init__.py +0 -1
- sqlspec-0.11.1/tests/unit/test_adapters/test_sqlite/test_config.py +0 -89
- sqlspec-0.11.1/tests/unit/test_base.py +0 -300
- sqlspec-0.11.1/tests/unit/test_statement.py +0 -287
- sqlspec-0.11.1/tests/unit/test_typing.py +0 -280
- sqlspec-0.11.1/tests/unit/test_utils/__init__.py +0 -0
- sqlspec-0.11.1/tests/unit/test_utils/test_module_loader.py +0 -46
- sqlspec-0.11.1/tests/unit/test_utils/test_sync_tools.py +0 -76
- sqlspec-0.11.1/tests/unit/test_utils/test_text.py +0 -57
- sqlspec-0.11.1/tools/__init__.py +0 -0
- sqlspec-0.11.1/tools/sphinx_ext/missing_references.py +0 -130
- sqlspec-0.11.1/uv.lock +0 -4435
- {sqlspec-0.11.1 → sqlspec-0.16.2}/CONTRIBUTING.rst +0 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/LICENSE +0 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/NOTICE +0 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/adapters/__init__.py +0 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/extensions/__init__.py +0 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/sqlspec/py.typed +0 -0
- {sqlspec-0.11.1/tests → sqlspec-0.16.2/sqlspec/storage/backends}/__init__.py +0 -0
- {sqlspec-0.11.1/tests/integration/test_adapters/test_asyncpg → sqlspec-0.16.2/tests}/__init__.py +0 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/tests/fixtures/__init__.py +0 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/tests/integration/test_adapters/test_asyncmy/__init__.py +0 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/tests/integration/test_adapters/test_duckdb/__init__.py +0 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/tests/integration/test_adapters/test_oracledb/__init__.py +0 -0
- {sqlspec-0.11.1/tests/integration/test_adapters/test_bigquery → sqlspec-0.16.2/tools}/__init__.py +0 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/tools/build_docs.py +0 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/tools/pypi_readme.py +0 -0
- {sqlspec-0.11.1 → sqlspec-0.16.2}/tools/sphinx_ext/__init__.py +0 -0
|
@@ -17,7 +17,9 @@ site/
|
|
|
17
17
|
target/
|
|
18
18
|
.idea/
|
|
19
19
|
.vscode/
|
|
20
|
+
.claude/
|
|
20
21
|
.cursor/
|
|
22
|
+
.zed/
|
|
21
23
|
|
|
22
24
|
# files
|
|
23
25
|
**/*.so
|
|
@@ -31,3 +33,31 @@ target/
|
|
|
31
33
|
/docs/_build/
|
|
32
34
|
coverage.*
|
|
33
35
|
setup.py
|
|
36
|
+
tmp/
|
|
37
|
+
*.log
|
|
38
|
+
.bugs
|
|
39
|
+
.tmp
|
|
40
|
+
.todos
|
|
41
|
+
todo/
|
|
42
|
+
CLAUDE.md
|
|
43
|
+
CLAUDE.*.md
|
|
44
|
+
TODO*
|
|
45
|
+
.claudedocs
|
|
46
|
+
.env
|
|
47
|
+
GEMINI.md
|
|
48
|
+
GEMINI.*.md
|
|
49
|
+
.cursor/
|
|
50
|
+
.cursorrules
|
|
51
|
+
CLAUDE*.md
|
|
52
|
+
*CLAUDE*.md
|
|
53
|
+
requirements/*
|
|
54
|
+
tools/*.json
|
|
55
|
+
benchmarks/
|
|
56
|
+
.benchmark
|
|
57
|
+
*.db
|
|
58
|
+
*.db-journal
|
|
59
|
+
*.db-wal
|
|
60
|
+
*.db-shm
|
|
61
|
+
*.duckdb
|
|
62
|
+
.crush
|
|
63
|
+
CRUSH.md
|
|
@@ -7,7 +7,7 @@ repos:
|
|
|
7
7
|
- id: conventional-pre-commit
|
|
8
8
|
stages: [commit-msg]
|
|
9
9
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
10
|
-
rev:
|
|
10
|
+
rev: v6.0.0
|
|
11
11
|
hooks:
|
|
12
12
|
- id: check-ast
|
|
13
13
|
- id: check-case-conflict
|
|
@@ -17,7 +17,7 @@ repos:
|
|
|
17
17
|
- id: mixed-line-ending
|
|
18
18
|
- id: trailing-whitespace
|
|
19
19
|
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
|
20
|
-
rev: "v0.
|
|
20
|
+
rev: "v0.12.8"
|
|
21
21
|
hooks:
|
|
22
22
|
- id: ruff
|
|
23
23
|
args: ["--fix"]
|
|
@@ -29,7 +29,7 @@ repos:
|
|
|
29
29
|
additional_dependencies:
|
|
30
30
|
- tomli
|
|
31
31
|
- repo: https://github.com/python-formate/flake8-dunder-all
|
|
32
|
-
rev: v0.
|
|
32
|
+
rev: v0.5.0
|
|
33
33
|
hooks:
|
|
34
34
|
- id: ensure-dunder-all
|
|
35
35
|
exclude: "test*|tools"
|
|
@@ -48,6 +48,18 @@ install: destroy clean ## Install the project, depe
|
|
|
48
48
|
@uv sync --all-extras --dev
|
|
49
49
|
@echo "${OK} Installation complete! 🎉"
|
|
50
50
|
|
|
51
|
+
.PHONY: install-compiled
|
|
52
|
+
install-compiled: destroy clean ## Install with mypyc compilation for performance
|
|
53
|
+
@echo "${INFO} Starting fresh installation with mypyc compilation..."
|
|
54
|
+
@uv python pin 3.12 >/dev/null 2>&1
|
|
55
|
+
@uv venv >/dev/null 2>&1
|
|
56
|
+
@echo "${INFO} Installing in editable mode with mypyc compilation..."
|
|
57
|
+
@HATCH_BUILD_HOOKS_ENABLE=1 uv pip install -e .
|
|
58
|
+
@uv sync --all-extras --dev
|
|
59
|
+
@echo "${OK} Performance installation complete! 🚀"
|
|
60
|
+
@echo "${INFO} Verifying compilation..."
|
|
61
|
+
@find sqlspec -name "*.so" | wc -l | xargs -I {} echo "${OK} Compiled {} modules"
|
|
62
|
+
|
|
51
63
|
.PHONY: destroy
|
|
52
64
|
destroy: ## Destroy the virtual environment
|
|
53
65
|
@echo "${INFO} Destroying virtual environment... 🗑️"
|
|
@@ -83,6 +95,22 @@ build: ## Build the package
|
|
|
83
95
|
@uv build >/dev/null 2>&1
|
|
84
96
|
@echo "${OK} Package build complete"
|
|
85
97
|
|
|
98
|
+
.PHONY: build-performance
|
|
99
|
+
build-performance: ## Build package with mypyc compilation
|
|
100
|
+
@echo "${INFO} Building package with mypyc compilation... 📦"
|
|
101
|
+
@HATCH_BUILD_HOOKS_ENABLE=1 uv build >/dev/null 2>&1
|
|
102
|
+
@echo "${OK} Performance package build complete 🚀"
|
|
103
|
+
|
|
104
|
+
.PHONY: test-mypyc
|
|
105
|
+
test-mypyc: ## Test mypyc compilation on individual modules
|
|
106
|
+
@echo "${INFO} Testing mypyc compilation... 🔧"
|
|
107
|
+
@uv run mypyc --check-untyped-defs sqlspec/utils/statement_hashing.py
|
|
108
|
+
@uv run mypyc --check-untyped-defs sqlspec/utils/text.py
|
|
109
|
+
@uv run mypyc --check-untyped-defs sqlspec/utils/sync_tools.py
|
|
110
|
+
@uv run mypyc --check-untyped-defs sqlspec/statement/cache.py
|
|
111
|
+
@echo "${OK} Mypyc compilation tests passed ✨"
|
|
112
|
+
|
|
113
|
+
|
|
86
114
|
.PHONY: release
|
|
87
115
|
release: ## Bump version and create release tag
|
|
88
116
|
@echo "${INFO} Preparing for release... 📦"
|
|
@@ -108,6 +136,8 @@ clean: ## Cleanup temporary build a
|
|
|
108
136
|
@find . -name '*~' -exec rm -f {} + >/dev/null 2>&1
|
|
109
137
|
@find . -name '__pycache__' -exec rm -rf {} + >/dev/null 2>&1
|
|
110
138
|
@find . -name '.ipynb_checkpoints' -exec rm -rf {} + >/dev/null 2>&1
|
|
139
|
+
@find . -name '*.so' -exec rm -f {} + >/dev/null 2>&1
|
|
140
|
+
@find . -name '*.c' -exec rm -f {} + >/dev/null 2>&1
|
|
111
141
|
@echo "${OK} Working directory cleaned"
|
|
112
142
|
$(MAKE) docs-clean
|
|
113
143
|
|
|
@@ -215,6 +245,49 @@ docs-linkcheck-full: ## Run full documentation lin
|
|
|
215
245
|
@uv run sphinx-build -b linkcheck ./docs ./docs/_build -D linkcheck_anchors=0
|
|
216
246
|
@echo "${OK} Full link check complete"
|
|
217
247
|
|
|
248
|
+
# =============================================================================
|
|
249
|
+
# Development Infrastructure
|
|
250
|
+
# =============================================================================
|
|
251
|
+
|
|
252
|
+
.PHONY: infra-up
|
|
253
|
+
infra-up: ## Start development infrastructure (databases, storage)
|
|
254
|
+
@echo "${INFO} Starting development infrastructure..."
|
|
255
|
+
@./tools/local-infra.sh up
|
|
256
|
+
@echo "${OK} Development infrastructure ready ✨"
|
|
257
|
+
|
|
258
|
+
.PHONY: infra-down
|
|
259
|
+
infra-down: ## Stop development infrastructure
|
|
260
|
+
@echo "${INFO} Stopping development infrastructure..."
|
|
261
|
+
@./tools/local-infra.sh down --quiet
|
|
262
|
+
@echo "${OK} Development infrastructure stopped"
|
|
263
|
+
|
|
264
|
+
.PHONY: infra-status
|
|
265
|
+
infra-status: ## Show development infrastructure status
|
|
266
|
+
@./tools/local-infra.sh status
|
|
267
|
+
|
|
268
|
+
.PHONY: infra-cleanup
|
|
269
|
+
infra-cleanup: ## Clean up development infrastructure
|
|
270
|
+
@echo "${WARN} This will remove all development containers and volumes"
|
|
271
|
+
@./tools/local-infra.sh cleanup
|
|
272
|
+
|
|
273
|
+
.PHONY: infra-postgres
|
|
274
|
+
infra-postgres: ## Start only PostgreSQL
|
|
275
|
+
@echo "${INFO} Starting PostgreSQL..."
|
|
276
|
+
@./tools/local-infra.sh up postgres --quiet
|
|
277
|
+
@echo "${OK} PostgreSQL ready on port 5433"
|
|
278
|
+
|
|
279
|
+
.PHONY: infra-oracle
|
|
280
|
+
infra-oracle: ## Start only Oracle
|
|
281
|
+
@echo "${INFO} Starting Oracle..."
|
|
282
|
+
@./tools/local-infra.sh up oracle --quiet
|
|
283
|
+
@echo "${OK} Oracle ready on port 1522"
|
|
284
|
+
|
|
285
|
+
.PHONY: infra-mysql
|
|
286
|
+
infra-mysql: ## Start only MySQL
|
|
287
|
+
@echo "${INFO} Starting MySQL..."
|
|
288
|
+
@./tools/local-infra.sh up mysql --quiet
|
|
289
|
+
@echo "${OK} MySQL ready on port 3307"
|
|
290
|
+
|
|
218
291
|
# =============================================================================
|
|
219
292
|
# End of Makefile
|
|
220
293
|
# =============================================================================
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlspec
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.16.2
|
|
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/
|
|
@@ -12,43 +12,64 @@ License-File: LICENSE
|
|
|
12
12
|
License-File: NOTICE
|
|
13
13
|
Requires-Python: <4.0,>=3.9
|
|
14
14
|
Requires-Dist: eval-type-backport; python_version < '3.10'
|
|
15
|
-
Requires-Dist:
|
|
15
|
+
Requires-Dist: mypy-extensions
|
|
16
|
+
Requires-Dist: rich-click
|
|
17
|
+
Requires-Dist: sqlglot>=19.9.0
|
|
16
18
|
Requires-Dist: typing-extensions
|
|
17
19
|
Provides-Extra: adbc
|
|
18
20
|
Requires-Dist: adbc-driver-manager; extra == 'adbc'
|
|
19
21
|
Requires-Dist: pyarrow; extra == 'adbc'
|
|
20
22
|
Provides-Extra: aioodbc
|
|
21
23
|
Requires-Dist: aioodbc; extra == 'aioodbc'
|
|
24
|
+
Provides-Extra: aiosql
|
|
25
|
+
Requires-Dist: aiosql; extra == 'aiosql'
|
|
22
26
|
Provides-Extra: aiosqlite
|
|
23
27
|
Requires-Dist: aiosqlite; extra == 'aiosqlite'
|
|
24
28
|
Provides-Extra: asyncmy
|
|
25
29
|
Requires-Dist: asyncmy; extra == 'asyncmy'
|
|
26
30
|
Provides-Extra: asyncpg
|
|
27
31
|
Requires-Dist: asyncpg; extra == 'asyncpg'
|
|
32
|
+
Provides-Extra: attrs
|
|
33
|
+
Requires-Dist: attrs; extra == 'attrs'
|
|
34
|
+
Requires-Dist: cattrs; extra == 'attrs'
|
|
28
35
|
Provides-Extra: bigquery
|
|
29
36
|
Requires-Dist: google-cloud-bigquery; extra == 'bigquery'
|
|
37
|
+
Provides-Extra: cli
|
|
38
|
+
Requires-Dist: rich-click; extra == 'cli'
|
|
30
39
|
Provides-Extra: duckdb
|
|
31
40
|
Requires-Dist: duckdb; extra == 'duckdb'
|
|
32
41
|
Provides-Extra: fastapi
|
|
33
42
|
Requires-Dist: fastapi; extra == 'fastapi'
|
|
34
43
|
Provides-Extra: flask
|
|
35
44
|
Requires-Dist: flask; extra == 'flask'
|
|
45
|
+
Provides-Extra: fsspec
|
|
46
|
+
Requires-Dist: fsspec; extra == 'fsspec'
|
|
36
47
|
Provides-Extra: litestar
|
|
37
48
|
Requires-Dist: litestar; extra == 'litestar'
|
|
38
49
|
Provides-Extra: msgspec
|
|
39
50
|
Requires-Dist: msgspec; extra == 'msgspec'
|
|
51
|
+
Provides-Extra: mypyc
|
|
40
52
|
Provides-Extra: nanoid
|
|
41
53
|
Requires-Dist: fastnanoid>=0.4.1; extra == 'nanoid'
|
|
54
|
+
Provides-Extra: obstore
|
|
55
|
+
Requires-Dist: obstore; extra == 'obstore'
|
|
56
|
+
Provides-Extra: opentelemetry
|
|
57
|
+
Requires-Dist: opentelemetry-instrumentation; extra == 'opentelemetry'
|
|
42
58
|
Provides-Extra: oracledb
|
|
43
59
|
Requires-Dist: oracledb; extra == 'oracledb'
|
|
44
60
|
Provides-Extra: orjson
|
|
45
61
|
Requires-Dist: orjson; extra == 'orjson'
|
|
62
|
+
Provides-Extra: pandas
|
|
63
|
+
Requires-Dist: pandas; extra == 'pandas'
|
|
64
|
+
Requires-Dist: pyarrow; extra == 'pandas'
|
|
46
65
|
Provides-Extra: performance
|
|
47
66
|
Requires-Dist: msgspec; extra == 'performance'
|
|
48
67
|
Requires-Dist: sqlglot[rs]; extra == 'performance'
|
|
49
68
|
Provides-Extra: polars
|
|
50
69
|
Requires-Dist: polars; extra == 'polars'
|
|
51
70
|
Requires-Dist: pyarrow; extra == 'polars'
|
|
71
|
+
Provides-Extra: prometheus
|
|
72
|
+
Requires-Dist: prometheus-client; extra == 'prometheus'
|
|
52
73
|
Provides-Extra: psqlpy
|
|
53
74
|
Requires-Dist: psqlpy; extra == 'psqlpy'
|
|
54
75
|
Provides-Extra: psycopg
|
|
@@ -63,7 +84,7 @@ Requires-Dist: pymysql; extra == 'pymysql'
|
|
|
63
84
|
Provides-Extra: spanner
|
|
64
85
|
Requires-Dist: google-cloud-spanner; extra == 'spanner'
|
|
65
86
|
Provides-Extra: uuid
|
|
66
|
-
Requires-Dist: uuid-utils
|
|
87
|
+
Requires-Dist: uuid-utils; extra == 'uuid'
|
|
67
88
|
Description-Content-Type: text/markdown
|
|
68
89
|
|
|
69
90
|
# SQLSpec
|
|
@@ -72,18 +93,26 @@ Description-Content-Type: text/markdown
|
|
|
72
93
|
|
|
73
94
|
SQLSpec is an experimental Python library designed to streamline and modernize your SQL interactions across a variety of database systems. While still in its early stages, SQLSpec aims to provide a flexible, typed, and extensible interface for working with SQL in Python.
|
|
74
95
|
|
|
75
|
-
**Note**: SQLSpec is currently under active development and the API is subject to change.
|
|
96
|
+
**Note**: SQLSpec is currently under active development and the API is subject to change. It is not yet ready for production use. Contributions are welcome!
|
|
76
97
|
|
|
77
|
-
## Core Features (
|
|
98
|
+
## Core Features (Current and Planned)
|
|
99
|
+
|
|
100
|
+
### Currently Implemented
|
|
78
101
|
|
|
79
102
|
- **Consistent Database Session Interface**: Provides a consistent connectivity interface for interacting with one or more database systems, including SQLite, Postgres, DuckDB, MySQL, Oracle, SQL Server, Spanner, BigQuery, and more.
|
|
80
|
-
- **Emphasis on RAW SQL and Minimal Abstractions
|
|
103
|
+
- **Emphasis on RAW SQL and Minimal Abstractions**: SQLSpec is a library for working with SQL in Python. Its goals are to offer minimal abstractions between the user and the database. It does not aim to be an ORM library.
|
|
81
104
|
- **Type-Safe Queries**: Quickly map SQL queries to typed objects using libraries such as Pydantic, Msgspec, Attrs, etc.
|
|
82
|
-
- **Extensible Design**: Easily add support for new database dialects or extend existing functionality to meet your specific needs.
|
|
83
|
-
- **Minimal Dependencies**: SQLSpec is designed to be lightweight and can run on
|
|
84
|
-
- **Dynamic Query Manipulation**: Easily apply filters to pre-defined queries with a fluent, Pythonic API. Safely manipulate queries without the risk of SQL injection.
|
|
85
|
-
- **Dialect Validation and Conversion**: Use `sqlglot` to validate your SQL against specific dialects and seamlessly convert between them.
|
|
105
|
+
- **Extensible Design**: Easily add support for new database dialects or extend existing functionality to meet your specific needs. Easily add support for async and sync database drivers.
|
|
106
|
+
- **Minimal Dependencies**: SQLSpec is designed to be lightweight and can run on its own or with other libraries such as `litestar`, `fastapi`, `flask` and more. (Contributions welcome!)
|
|
86
107
|
- **Support for Async and Sync Database Drivers**: SQLSpec supports both async and sync database drivers, allowing you to choose the style that best fits your application.
|
|
108
|
+
|
|
109
|
+
### Experimental Features (API will change rapidly)
|
|
110
|
+
|
|
111
|
+
- **SQL Builder API**: Type-safe query builder with method chaining (experimental and subject to significant changes)
|
|
112
|
+
- **Dynamic Query Manipulation**: Apply filters to pre-defined queries with a fluent API. Safely manipulate queries without SQL injection risk.
|
|
113
|
+
- **Dialect Validation and Conversion**: Use `sqlglot` to validate your SQL against specific dialects and seamlessly convert between them.
|
|
114
|
+
- **Storage Operations**: Direct export to Parquet, CSV, JSON with Arrow integration
|
|
115
|
+
- **Instrumentation**: OpenTelemetry and Prometheus metrics support
|
|
87
116
|
- **Basic Migration Management**: A mechanism to generate empty migration files where you can add your own SQL and intelligently track which migrations have been applied.
|
|
88
117
|
|
|
89
118
|
## What SQLSpec Is Not (Yet)
|
|
@@ -94,16 +123,60 @@ SQLSpec is a work in progress. While it offers a solid foundation for modern SQL
|
|
|
94
123
|
|
|
95
124
|
We've talked about what SQLSpec is not, so let's look at what it can do.
|
|
96
125
|
|
|
97
|
-
These are just a few
|
|
126
|
+
These are just a few examples that demonstrate SQLSpec's flexibility. Each of the bundled adapters offers the same config and driver interfaces.
|
|
127
|
+
|
|
128
|
+
### Basic Usage
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from sqlspec import SQLSpec
|
|
132
|
+
from sqlspec.adapters.sqlite import SqliteConfig
|
|
133
|
+
from pydantic import BaseModel
|
|
134
|
+
# Create SQLSpec instance and configure database
|
|
135
|
+
sql = SQLSpec()
|
|
136
|
+
config = sql.add_config(SqliteConfig(database=":memory:"))
|
|
137
|
+
|
|
138
|
+
# Execute queries with automatic result mapping
|
|
139
|
+
with sql.provide_session(config) as session:
|
|
140
|
+
# Simple query
|
|
141
|
+
result = session.execute("SELECT 'Hello, SQLSpec!' as message")
|
|
142
|
+
print(result.get_first()) # {'message': 'Hello, SQLSpec!'}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### SQL Builder Example (Experimental)
|
|
146
|
+
|
|
147
|
+
**Warning**: The SQL Builder API is highly experimental and will change significantly.
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from sqlspec import sql
|
|
151
|
+
|
|
152
|
+
# 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 = ?
|
|
155
|
+
|
|
156
|
+
# More complex example with joins
|
|
157
|
+
query = (
|
|
158
|
+
sql.select("u.name", "COUNT(o.id) as order_count")
|
|
159
|
+
.from_("users u")
|
|
160
|
+
.left_join("orders o", "u.id = o.user_id")
|
|
161
|
+
.where("u.created_at > ?", "2024-01-01")
|
|
162
|
+
.group_by("u.name")
|
|
163
|
+
.having("COUNT(o.id) > ?", 5)
|
|
164
|
+
.order_by("order_count", desc=True)
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
# Execute the built query
|
|
168
|
+
with sql.provide_session(config) as session:
|
|
169
|
+
results = session.execute(query.build())
|
|
170
|
+
```
|
|
98
171
|
|
|
99
172
|
### DuckDB LLM
|
|
100
173
|
|
|
101
|
-
This is a quick implementation using some of the built
|
|
174
|
+
This is a quick implementation using some of the built-in Secret and Extension management features of SQLSpec's DuckDB integration.
|
|
102
175
|
|
|
103
|
-
It allows you to communicate with any compatible OpenAPI conversations endpoint (such as Ollama).
|
|
176
|
+
It allows you to communicate with any compatible OpenAPI conversations endpoint (such as Ollama). This example:
|
|
104
177
|
|
|
105
178
|
- auto installs the `open_prompt` DuckDB extensions
|
|
106
|
-
- automatically creates the correct `open_prompt`
|
|
179
|
+
- automatically creates the correct `open_prompt` compatible secret required to use the extension
|
|
107
180
|
|
|
108
181
|
```py
|
|
109
182
|
# /// script
|
|
@@ -148,12 +221,12 @@ with sql.provide_session(etl_config) as session:
|
|
|
148
221
|
|
|
149
222
|
### DuckDB Gemini Embeddings
|
|
150
223
|
|
|
151
|
-
In this example, we are again using DuckDB.
|
|
224
|
+
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.
|
|
152
225
|
|
|
153
|
-
This example will
|
|
226
|
+
This example will:
|
|
154
227
|
|
|
155
228
|
- auto installs the `http_client` and `vss` (vector similarity search) DuckDB extensions
|
|
156
|
-
- when a connection is created, it ensures that the `generate_embeddings` macro exists in the DuckDB database
|
|
229
|
+
- when a connection is created, it ensures that the `generate_embeddings` macro exists in the DuckDB database
|
|
157
230
|
- Execute a simple query to call the Google API
|
|
158
231
|
|
|
159
232
|
```py
|
|
@@ -199,8 +272,8 @@ etl_config = sql.add_config(
|
|
|
199
272
|
)
|
|
200
273
|
)
|
|
201
274
|
with sql.provide_session(etl_config) as session:
|
|
202
|
-
result = session.
|
|
203
|
-
print(result) # result is a dictionary when `schema_type` is omitted.
|
|
275
|
+
result = session.execute("SELECT generate_embedding('example text')")
|
|
276
|
+
print(result.get_first()) # result is a dictionary when `schema_type` is omitted.
|
|
204
277
|
```
|
|
205
278
|
|
|
206
279
|
### Basic Litestar Integration
|
|
@@ -215,11 +288,10 @@ In this example we are going to demonstrate how to create a basic configuration
|
|
|
215
288
|
# ]
|
|
216
289
|
# ///
|
|
217
290
|
|
|
218
|
-
from aiosqlite import Connection
|
|
219
291
|
from litestar import Litestar, get
|
|
220
292
|
|
|
221
293
|
from sqlspec.adapters.aiosqlite import AiosqliteConfig, AiosqliteDriver
|
|
222
|
-
from sqlspec.extensions.litestar import SQLSpec
|
|
294
|
+
from sqlspec.extensions.litestar import DatabaseConfig, SQLSpec
|
|
223
295
|
|
|
224
296
|
|
|
225
297
|
@get("/")
|
|
@@ -227,15 +299,18 @@ async def simple_sqlite(db_session: AiosqliteDriver) -> dict[str, str]:
|
|
|
227
299
|
return await db_session.select_one("SELECT 'Hello, world!' AS greeting")
|
|
228
300
|
|
|
229
301
|
|
|
230
|
-
sqlspec = SQLSpec(
|
|
231
|
-
config=
|
|
302
|
+
sqlspec = SQLSpec(
|
|
303
|
+
config=DatabaseConfig(
|
|
304
|
+
config=AiosqliteConfig(),
|
|
305
|
+
commit_mode="autocommit"
|
|
306
|
+
)
|
|
232
307
|
)
|
|
233
308
|
app = Litestar(route_handlers=[simple_sqlite], plugins=[sqlspec])
|
|
234
309
|
```
|
|
235
310
|
|
|
236
311
|
## Inspiration and Future Direction
|
|
237
312
|
|
|
238
|
-
SQLSpec originally drew inspiration from features found in the `aiosql` library.
|
|
313
|
+
SQLSpec originally drew inspiration from features found in the `aiosql` library. This is a great library for working with and executing SQL stored in files. It's unclear how much of an overlap there will be between the two libraries, but it's possible that some features will be contributed back to `aiosql` where appropriate.
|
|
239
314
|
|
|
240
315
|
## Current Focus: Universal Connectivity
|
|
241
316
|
|
|
@@ -275,9 +350,10 @@ This list is not final. If you have a driver you'd like to see added, please ope
|
|
|
275
350
|
- `litestar/`: Litestar framework integration ✅
|
|
276
351
|
- `fastapi/`: Future home of `fastapi` integration.
|
|
277
352
|
- `flask/`: Future home of `flask` integration.
|
|
278
|
-
- `*/`: Future home of your favorite framework integration
|
|
353
|
+
- `*/`: Future home of your favorite framework integration
|
|
279
354
|
- `base.py`: Contains base protocols for database configurations.
|
|
280
|
-
- `
|
|
355
|
+
- `statement/`: Contains the SQL statement system with builders, validation, and transformation.
|
|
356
|
+
- `storage/`: Contains unified storage operations for data import/export.
|
|
281
357
|
- `utils/`: Contains utility functions used throughout the project.
|
|
282
358
|
- `exceptions.py`: Contains custom exceptions for SQLSpec.
|
|
283
359
|
- `typing.py`: Contains type hints, type guards and several facades for optional libraries that are not required for the core functionality of SQLSpec.
|
|
@@ -4,18 +4,26 @@
|
|
|
4
4
|
|
|
5
5
|
SQLSpec is an experimental Python library designed to streamline and modernize your SQL interactions across a variety of database systems. While still in its early stages, SQLSpec aims to provide a flexible, typed, and extensible interface for working with SQL in Python.
|
|
6
6
|
|
|
7
|
-
**Note**: SQLSpec is currently under active development and the API is subject to change.
|
|
7
|
+
**Note**: SQLSpec is currently under active development and the API is subject to change. It is not yet ready for production use. Contributions are welcome!
|
|
8
8
|
|
|
9
|
-
## Core Features (
|
|
9
|
+
## Core Features (Current and Planned)
|
|
10
|
+
|
|
11
|
+
### Currently Implemented
|
|
10
12
|
|
|
11
13
|
- **Consistent Database Session Interface**: Provides a consistent connectivity interface for interacting with one or more database systems, including SQLite, Postgres, DuckDB, MySQL, Oracle, SQL Server, Spanner, BigQuery, and more.
|
|
12
|
-
- **Emphasis on RAW SQL and Minimal Abstractions
|
|
14
|
+
- **Emphasis on RAW SQL and Minimal Abstractions**: SQLSpec is a library for working with SQL in Python. Its goals are to offer minimal abstractions between the user and the database. It does not aim to be an ORM library.
|
|
13
15
|
- **Type-Safe Queries**: Quickly map SQL queries to typed objects using libraries such as Pydantic, Msgspec, Attrs, etc.
|
|
14
|
-
- **Extensible Design**: Easily add support for new database dialects or extend existing functionality to meet your specific needs.
|
|
15
|
-
- **Minimal Dependencies**: SQLSpec is designed to be lightweight and can run on
|
|
16
|
-
- **Dynamic Query Manipulation**: Easily apply filters to pre-defined queries with a fluent, Pythonic API. Safely manipulate queries without the risk of SQL injection.
|
|
17
|
-
- **Dialect Validation and Conversion**: Use `sqlglot` to validate your SQL against specific dialects and seamlessly convert between them.
|
|
16
|
+
- **Extensible Design**: Easily add support for new database dialects or extend existing functionality to meet your specific needs. Easily add support for async and sync database drivers.
|
|
17
|
+
- **Minimal Dependencies**: SQLSpec is designed to be lightweight and can run on its own or with other libraries such as `litestar`, `fastapi`, `flask` and more. (Contributions welcome!)
|
|
18
18
|
- **Support for Async and Sync Database Drivers**: SQLSpec supports both async and sync database drivers, allowing you to choose the style that best fits your application.
|
|
19
|
+
|
|
20
|
+
### Experimental Features (API will change rapidly)
|
|
21
|
+
|
|
22
|
+
- **SQL Builder API**: Type-safe query builder with method chaining (experimental and subject to significant changes)
|
|
23
|
+
- **Dynamic Query Manipulation**: Apply filters to pre-defined queries with a fluent API. Safely manipulate queries without SQL injection risk.
|
|
24
|
+
- **Dialect Validation and Conversion**: Use `sqlglot` to validate your SQL against specific dialects and seamlessly convert between them.
|
|
25
|
+
- **Storage Operations**: Direct export to Parquet, CSV, JSON with Arrow integration
|
|
26
|
+
- **Instrumentation**: OpenTelemetry and Prometheus metrics support
|
|
19
27
|
- **Basic Migration Management**: A mechanism to generate empty migration files where you can add your own SQL and intelligently track which migrations have been applied.
|
|
20
28
|
|
|
21
29
|
## What SQLSpec Is Not (Yet)
|
|
@@ -26,16 +34,60 @@ SQLSpec is a work in progress. While it offers a solid foundation for modern SQL
|
|
|
26
34
|
|
|
27
35
|
We've talked about what SQLSpec is not, so let's look at what it can do.
|
|
28
36
|
|
|
29
|
-
These are just a few
|
|
37
|
+
These are just a few examples that demonstrate SQLSpec's flexibility. Each of the bundled adapters offers the same config and driver interfaces.
|
|
38
|
+
|
|
39
|
+
### Basic Usage
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from sqlspec import SQLSpec
|
|
43
|
+
from sqlspec.adapters.sqlite import SqliteConfig
|
|
44
|
+
from pydantic import BaseModel
|
|
45
|
+
# Create SQLSpec instance and configure database
|
|
46
|
+
sql = SQLSpec()
|
|
47
|
+
config = sql.add_config(SqliteConfig(database=":memory:"))
|
|
48
|
+
|
|
49
|
+
# Execute queries with automatic result mapping
|
|
50
|
+
with sql.provide_session(config) as session:
|
|
51
|
+
# Simple query
|
|
52
|
+
result = session.execute("SELECT 'Hello, SQLSpec!' as message")
|
|
53
|
+
print(result.get_first()) # {'message': 'Hello, SQLSpec!'}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### SQL Builder Example (Experimental)
|
|
57
|
+
|
|
58
|
+
**Warning**: The SQL Builder API is highly experimental and will change significantly.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from sqlspec import sql
|
|
62
|
+
|
|
63
|
+
# Build a simple query
|
|
64
|
+
query = sql.select("id", "name", "email").from_("users").where("active = ?", True)
|
|
65
|
+
print(query.build().sql) # SELECT id, name, email FROM users WHERE active = ?
|
|
66
|
+
|
|
67
|
+
# More complex example with joins
|
|
68
|
+
query = (
|
|
69
|
+
sql.select("u.name", "COUNT(o.id) as order_count")
|
|
70
|
+
.from_("users u")
|
|
71
|
+
.left_join("orders o", "u.id = o.user_id")
|
|
72
|
+
.where("u.created_at > ?", "2024-01-01")
|
|
73
|
+
.group_by("u.name")
|
|
74
|
+
.having("COUNT(o.id) > ?", 5)
|
|
75
|
+
.order_by("order_count", desc=True)
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
# Execute the built query
|
|
79
|
+
with sql.provide_session(config) as session:
|
|
80
|
+
results = session.execute(query.build())
|
|
81
|
+
```
|
|
30
82
|
|
|
31
83
|
### DuckDB LLM
|
|
32
84
|
|
|
33
|
-
This is a quick implementation using some of the built
|
|
85
|
+
This is a quick implementation using some of the built-in Secret and Extension management features of SQLSpec's DuckDB integration.
|
|
34
86
|
|
|
35
|
-
It allows you to communicate with any compatible OpenAPI conversations endpoint (such as Ollama).
|
|
87
|
+
It allows you to communicate with any compatible OpenAPI conversations endpoint (such as Ollama). This example:
|
|
36
88
|
|
|
37
89
|
- auto installs the `open_prompt` DuckDB extensions
|
|
38
|
-
- automatically creates the correct `open_prompt`
|
|
90
|
+
- automatically creates the correct `open_prompt` compatible secret required to use the extension
|
|
39
91
|
|
|
40
92
|
```py
|
|
41
93
|
# /// script
|
|
@@ -80,12 +132,12 @@ with sql.provide_session(etl_config) as session:
|
|
|
80
132
|
|
|
81
133
|
### DuckDB Gemini Embeddings
|
|
82
134
|
|
|
83
|
-
In this example, we are again using DuckDB.
|
|
135
|
+
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.
|
|
84
136
|
|
|
85
|
-
This example will
|
|
137
|
+
This example will:
|
|
86
138
|
|
|
87
139
|
- auto installs the `http_client` and `vss` (vector similarity search) DuckDB extensions
|
|
88
|
-
- when a connection is created, it ensures that the `generate_embeddings` macro exists in the DuckDB database
|
|
140
|
+
- when a connection is created, it ensures that the `generate_embeddings` macro exists in the DuckDB database
|
|
89
141
|
- Execute a simple query to call the Google API
|
|
90
142
|
|
|
91
143
|
```py
|
|
@@ -131,8 +183,8 @@ etl_config = sql.add_config(
|
|
|
131
183
|
)
|
|
132
184
|
)
|
|
133
185
|
with sql.provide_session(etl_config) as session:
|
|
134
|
-
result = session.
|
|
135
|
-
print(result) # result is a dictionary when `schema_type` is omitted.
|
|
186
|
+
result = session.execute("SELECT generate_embedding('example text')")
|
|
187
|
+
print(result.get_first()) # result is a dictionary when `schema_type` is omitted.
|
|
136
188
|
```
|
|
137
189
|
|
|
138
190
|
### Basic Litestar Integration
|
|
@@ -147,11 +199,10 @@ In this example we are going to demonstrate how to create a basic configuration
|
|
|
147
199
|
# ]
|
|
148
200
|
# ///
|
|
149
201
|
|
|
150
|
-
from aiosqlite import Connection
|
|
151
202
|
from litestar import Litestar, get
|
|
152
203
|
|
|
153
204
|
from sqlspec.adapters.aiosqlite import AiosqliteConfig, AiosqliteDriver
|
|
154
|
-
from sqlspec.extensions.litestar import SQLSpec
|
|
205
|
+
from sqlspec.extensions.litestar import DatabaseConfig, SQLSpec
|
|
155
206
|
|
|
156
207
|
|
|
157
208
|
@get("/")
|
|
@@ -159,15 +210,18 @@ async def simple_sqlite(db_session: AiosqliteDriver) -> dict[str, str]:
|
|
|
159
210
|
return await db_session.select_one("SELECT 'Hello, world!' AS greeting")
|
|
160
211
|
|
|
161
212
|
|
|
162
|
-
sqlspec = SQLSpec(
|
|
163
|
-
config=
|
|
213
|
+
sqlspec = SQLSpec(
|
|
214
|
+
config=DatabaseConfig(
|
|
215
|
+
config=AiosqliteConfig(),
|
|
216
|
+
commit_mode="autocommit"
|
|
217
|
+
)
|
|
164
218
|
)
|
|
165
219
|
app = Litestar(route_handlers=[simple_sqlite], plugins=[sqlspec])
|
|
166
220
|
```
|
|
167
221
|
|
|
168
222
|
## Inspiration and Future Direction
|
|
169
223
|
|
|
170
|
-
SQLSpec originally drew inspiration from features found in the `aiosql` library.
|
|
224
|
+
SQLSpec originally drew inspiration from features found in the `aiosql` library. This is a great library for working with and executing SQL stored in files. It's unclear how much of an overlap there will be between the two libraries, but it's possible that some features will be contributed back to `aiosql` where appropriate.
|
|
171
225
|
|
|
172
226
|
## Current Focus: Universal Connectivity
|
|
173
227
|
|
|
@@ -207,9 +261,10 @@ This list is not final. If you have a driver you'd like to see added, please ope
|
|
|
207
261
|
- `litestar/`: Litestar framework integration ✅
|
|
208
262
|
- `fastapi/`: Future home of `fastapi` integration.
|
|
209
263
|
- `flask/`: Future home of `flask` integration.
|
|
210
|
-
- `*/`: Future home of your favorite framework integration
|
|
264
|
+
- `*/`: Future home of your favorite framework integration
|
|
211
265
|
- `base.py`: Contains base protocols for database configurations.
|
|
212
|
-
- `
|
|
266
|
+
- `statement/`: Contains the SQL statement system with builders, validation, and transformation.
|
|
267
|
+
- `storage/`: Contains unified storage operations for data import/export.
|
|
213
268
|
- `utils/`: Contains utility functions used throughout the project.
|
|
214
269
|
- `exceptions.py`: Contains custom exceptions for SQLSpec.
|
|
215
270
|
- `typing.py`: Contains type hints, type guards and several facades for optional libraries that are not required for the core functionality of SQLSpec.
|