sqlspec 0.5.0__tar.gz → 0.6.0__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 (80) hide show
  1. {sqlspec-0.5.0 → sqlspec-0.6.0}/.pre-commit-config.yaml +2 -2
  2. sqlspec-0.6.0/LICENSE +21 -0
  3. {sqlspec-0.5.0 → sqlspec-0.6.0}/PKG-INFO +17 -15
  4. {sqlspec-0.5.0 → sqlspec-0.6.0}/README.md +14 -13
  5. {sqlspec-0.5.0 → sqlspec-0.6.0}/pyproject.toml +3 -65
  6. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/__metadata__.py +1 -1
  7. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/adbc/config.py +2 -2
  8. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/aiosqlite/config.py +11 -18
  9. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/asyncmy/config.py +2 -2
  10. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/asyncpg/config.py +4 -8
  11. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/duckdb/config.py +2 -2
  12. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/oracledb/config/_asyncio.py +14 -7
  13. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/oracledb/config/_common.py +2 -20
  14. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/oracledb/config/_sync.py +13 -6
  15. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/psycopg/config/_async.py +10 -8
  16. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/psycopg/config/_common.py +2 -17
  17. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/psycopg/config/_sync.py +10 -9
  18. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/sqlite/config.py +2 -2
  19. sqlspec-0.6.0/sqlspec/base.py +221 -0
  20. sqlspec-0.6.0/sqlspec/extensions/litestar/plugin.py +42 -0
  21. sqlspec-0.6.0/tests/unit/test_adapters/test_aiosqlite/test_config.py +108 -0
  22. sqlspec-0.6.0/tests/unit/test_adapters/test_asyncpg/__init__.py +1 -0
  23. sqlspec-0.6.0/tests/unit/test_adapters/test_asyncpg/test_config.py +159 -0
  24. {sqlspec-0.5.0 → sqlspec-0.6.0}/tests/unit/test_adapters/test_duckdb/test_config.py +4 -4
  25. sqlspec-0.6.0/tests/unit/test_adapters/test_oracledb/__init__.py +1 -0
  26. sqlspec-0.6.0/tests/unit/test_adapters/test_oracledb/test_config.py +335 -0
  27. sqlspec-0.6.0/tests/unit/test_adapters/test_psycopg/test_async_config.py +167 -0
  28. sqlspec-0.6.0/tests/unit/test_adapters/test_psycopg/test_sync_config.py +152 -0
  29. sqlspec-0.6.0/tests/unit/test_adapters/test_sqlite/__init__.py +1 -0
  30. sqlspec-0.6.0/tests/unit/test_adapters/test_sqlite/test_config.py +87 -0
  31. sqlspec-0.6.0/tests/unit/test_base.py +229 -0
  32. sqlspec-0.6.0/tests/unit/test_utils/__init__.py +0 -0
  33. {sqlspec-0.5.0 → sqlspec-0.6.0}/tests/unit/test_utils/test_module_loader.py +3 -3
  34. sqlspec-0.6.0/tools/__init__.py +0 -0
  35. {sqlspec-0.5.0 → sqlspec-0.6.0}/uv.lock +430 -447
  36. sqlspec-0.5.0/sqlspec/base.py +0 -87
  37. sqlspec-0.5.0/sqlspec/extensions/litestar/plugin.py +0 -34
  38. {sqlspec-0.5.0 → sqlspec-0.6.0}/.gitignore +0 -0
  39. {sqlspec-0.5.0 → sqlspec-0.6.0}/CONTRIBUTING.rst +0 -0
  40. {sqlspec-0.5.0 → sqlspec-0.6.0}/Makefile +0 -0
  41. {sqlspec-0.5.0 → sqlspec-0.6.0}/NOTICE +0 -0
  42. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/__init__.py +0 -0
  43. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/_serialization.py +0 -0
  44. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/_typing.py +0 -0
  45. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/__init__.py +0 -0
  46. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/adbc/__init__.py +0 -0
  47. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/aiosqlite/__init__.py +0 -0
  48. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/asyncmy/__init__.py +0 -0
  49. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/asyncpg/__init__.py +0 -0
  50. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/duckdb/__init__.py +0 -0
  51. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/oracledb/__init__.py +0 -0
  52. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/oracledb/config/__init__.py +0 -0
  53. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/psycopg/__init__.py +0 -0
  54. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/psycopg/config/__init__.py +0 -0
  55. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/adapters/sqlite/__init__.py +0 -0
  56. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/exceptions.py +0 -0
  57. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/extensions/__init__.py +0 -0
  58. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/extensions/litestar/__init__.py +0 -0
  59. /sqlspec-0.5.0/sqlspec/py.typed → /sqlspec-0.6.0/sqlspec/extensions/litestar/config.py +0 -0
  60. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/filters.py +0 -0
  61. /sqlspec-0.5.0/sqlspec/utils/__init__.py → /sqlspec-0.6.0/sqlspec/py.typed +0 -0
  62. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/typing.py +0 -0
  63. {sqlspec-0.5.0/tests → sqlspec-0.6.0/sqlspec/utils}/__init__.py +0 -0
  64. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/utils/deprecation.py +0 -0
  65. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/utils/fixtures.py +0 -0
  66. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/utils/module_loader.py +0 -0
  67. {sqlspec-0.5.0 → sqlspec-0.6.0}/sqlspec/utils/text.py +0 -0
  68. {sqlspec-0.5.0/tests/unit → sqlspec-0.6.0/tests}/__init__.py +0 -0
  69. {sqlspec-0.5.0 → sqlspec-0.6.0}/tests/conftest.py +0 -0
  70. {sqlspec-0.5.0/tests/unit/test_adapters → sqlspec-0.6.0/tests/integration}/__init__.py +0 -0
  71. {sqlspec-0.5.0/tests/unit/test_adapters/test_duckdb → sqlspec-0.6.0/tests/unit}/__init__.py +0 -0
  72. {sqlspec-0.5.0/tests/unit/test_utils → sqlspec-0.6.0/tests/unit/test_adapters}/__init__.py +0 -0
  73. {sqlspec-0.5.0/tools → sqlspec-0.6.0/tests/unit/test_adapters/test_duckdb}/__init__.py +0 -0
  74. {sqlspec-0.5.0 → sqlspec-0.6.0}/tests/unit/test_typing.py +0 -0
  75. {sqlspec-0.5.0 → sqlspec-0.6.0}/tests/unit/test_utils/test_text.py +0 -0
  76. {sqlspec-0.5.0 → sqlspec-0.6.0}/tools/build_docs.py +0 -0
  77. {sqlspec-0.5.0 → sqlspec-0.6.0}/tools/pypi_readme.py +0 -0
  78. {sqlspec-0.5.0 → sqlspec-0.6.0}/tools/sphinx_ext/__init__.py +0 -0
  79. {sqlspec-0.5.0 → sqlspec-0.6.0}/tools/sphinx_ext/changelog.py +0 -0
  80. {sqlspec-0.5.0 → sqlspec-0.6.0}/tools/sphinx_ext/missing_references.py +0 -0
@@ -17,13 +17,13 @@ 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.9.1"
20
+ rev: "v0.9.4"
21
21
  hooks:
22
22
  - id: ruff
23
23
  args: ["--fix"]
24
24
  - id: ruff-format
25
25
  - repo: https://github.com/codespell-project/codespell
26
- rev: v2.3.0
26
+ rev: v2.4.1
27
27
  hooks:
28
28
  - id: codespell
29
29
  additional_dependencies:
sqlspec-0.6.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Litestar Organization
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,9 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlspec
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: SQL Experiments in Python
5
5
  Author-email: Cody Fincher <cody@litestar.dev>
6
6
  Maintainer-email: Litestar Developers <hello@litestar.dev>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
7
9
  License-File: NOTICE
8
10
  Requires-Python: <4.0,>=3.9
9
11
  Requires-Dist: eval-type-backport; python_version < '3.10'
@@ -35,7 +37,6 @@ Requires-Dist: msgspec; extra == 'msgspec'
35
37
  Provides-Extra: oracledb
36
38
  Requires-Dist: oracledb; extra == 'oracledb'
37
39
  Provides-Extra: performance
38
- Requires-Dist: google-re2; (sys_platform == 'linux') and extra == 'performance'
39
40
  Requires-Dist: sqlglot[rs]; extra == 'performance'
40
41
  Provides-Extra: psycopg
41
42
  Requires-Dist: psycopg[binary,pool]; extra == 'psycopg'
@@ -57,30 +58,31 @@ SQLSpec is an experimental Python library designed to streamline and modernize y
57
58
 
58
59
  **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!
59
60
 
60
- ### Core Features (Planned but subject to change, removal or redesign)
61
+ ## Core Features (Planned but subject to change, removal or redesign)
61
62
 
62
63
  - **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.
63
64
  - **Emphasis on RAW SQL and Minimal Abstractions and Performance**: SQLSpec is a library for working with SQL in Python. It's goals are to offer minimal abstractions between the user and the database. It does not aim to be an ORM library.
64
- - **Type-Safe Queries**: Quickly map SQL queries to typed objects using libraries such as Pydantic, Msqgspec, Attrs, etc.
65
+ - **Type-Safe Queries**: Quickly map SQL queries to typed objects using libraries such as Pydantic, Msgspec, Attrs, etc.
65
66
  - **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.
66
67
  - **Minimal Dependencies**: SQLSpec is designed to be lightweight and can run on it's own or with other libraries such as `litestar`, `fastapi`, `flask` and more. (Contributions welcome!)
67
68
  - **Dynamic Query Manipulation**: Easily apply filters to pre-defined queries with a fluent, Pythonic API. Safely manipulate queries without the risk of SQL injection.
68
69
  - **Dialect Validation and Conversion**: Use `sqlglot` to validate your SQL against specific dialects and seamlessly convert between them.
69
70
  - **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.
71
+ - **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.
70
72
 
71
- ### What SQLSpec Is Not (Yet)
73
+ ## What SQLSpec Is Not (Yet)
72
74
 
73
75
  SQLSpec is a work in progress. While it offers a solid foundation for modern SQL interactions, it does not yet include every feature you might find in a mature ORM or database toolkit. The focus is on building a robust, flexible core that can be extended over time.
74
76
 
75
- ### Inspiration and Future Direction
77
+ ## Inspiration and Future Direction
76
78
 
77
79
  SQLSpec originally drew inspiration from features found in the `aiosql` library. This is a great library for working with and executed 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.
78
80
 
79
- ### Current Focus: Universal Connectivity
81
+ ## Current Focus: Universal Connectivity
80
82
 
81
83
  The primary goal at this stage is to establish a **native connectivity interface** that works seamlessly across all supported database environments. This means you can connect to any of the supported databases using a consistent API, regardless of the underlying driver or dialect.
82
84
 
83
- ### Adapters: Completed, In Progress, and Planned
85
+ ## Adapters: Completed, In Progress, and Planned
84
86
 
85
87
  This list is not final. If you have a driver you'd like to see added, please open an issue or submit a PR!
86
88
 
@@ -98,13 +100,13 @@ This list is not final. If you have a driver you'd like to see added, please ope
98
100
  | [`oracledb`](https://oracle.github.io/python-oracledb/) | Oracle | Async | ✅ |
99
101
  | [`oracledb`](https://oracle.github.io/python-oracledb/) | Oracle | Sync | ✅ |
100
102
  | [`duckdb`](https://duckdb.org/) | DuckDB | Sync | ✅ |
101
- | [`bigquery`](https://googleapis.dev/python/bigquery/latest/index.html) | BigQuery | Sync | 🗓️ Planned |
102
- | [`spanner`](https://googleapis.dev/python/spanner/latest/index.html) | Spanner | Sync | 🗓️ Planned |
103
- | [`sqlserver`](https://docs.microsoft.com/en-us/sql/connect/python/pyodbc/python-sql-driver-for-pyodbc?view=sql-server-ver16) | SQL Server | Sync | 🗓️ Planned |
104
- | [`mysql`](https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysql-connector-python.html) | MySQL | Sync | 🗓️ Planned |
105
- | [`snowflake`](https://docs.snowflake.com)
103
+ | [`bigquery`](https://googleapis.dev/python/bigquery/latest/index.html) | BigQuery | Sync | 🗓️ |
104
+ | [`spanner`](https://googleapis.dev/python/spanner/latest/index.html) | Spanner | Sync | 🗓️ |
105
+ | [`sqlserver`](https://docs.microsoft.com/en-us/sql/connect/python/pyodbc/python-sql-driver-for-pyodbc?view=sql-server-ver16) | SQL Server | Sync | 🗓️ |
106
+ | [`mysql`](https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysql-connector-python.html) | MySQL | Sync | 🗓️ |
107
+ | [`snowflake`](https://docs.snowflake.com) | Snowflake | Sync | 🗓️ |
106
108
 
107
- ### Proposed Project Structure
109
+ ## Proposed Project Structure
108
110
 
109
111
  - `sqlspec/`:
110
112
  - `adapters/`: Contains all database drivers and associated configuration.
@@ -119,7 +121,7 @@ This list is not final. If you have a driver you'd like to see added, please ope
119
121
  - `exceptions.py`: Contains custom exceptions for SQLSpec.
120
122
  - `typing.py`: Contains type hints, type guards and several facades for optional libraries that are not required for the core functionality of SQLSpec.
121
123
 
122
- ### Get Involved
124
+ ## Get Involved
123
125
 
124
126
  SQLSpec is an open-source project, and contributions are welcome! Whether you're interested in adding support for new databases, improving the query interface, or simply providing feedback, your input is valuable.
125
127
 
@@ -6,30 +6,31 @@ SQLSpec is an experimental Python library designed to streamline and modernize y
6
6
 
7
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 (Planned but subject to change, removal or redesign)
9
+ ## Core Features (Planned but subject to change, removal or redesign)
10
10
 
11
11
  - **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
12
  - **Emphasis on RAW SQL and Minimal Abstractions and Performance**: SQLSpec is a library for working with SQL in Python. It's goals are to offer minimal abstractions between the user and the database. It does not aim to be an ORM library.
13
- - **Type-Safe Queries**: Quickly map SQL queries to typed objects using libraries such as Pydantic, Msqgspec, Attrs, etc.
13
+ - **Type-Safe Queries**: Quickly map SQL queries to typed objects using libraries such as Pydantic, Msgspec, Attrs, etc.
14
14
  - **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.
15
15
  - **Minimal Dependencies**: SQLSpec is designed to be lightweight and can run on it's own or with other libraries such as `litestar`, `fastapi`, `flask` and more. (Contributions welcome!)
16
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
17
  - **Dialect Validation and Conversion**: Use `sqlglot` to validate your SQL against specific dialects and seamlessly convert between them.
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
+ - **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.
19
20
 
20
- ### What SQLSpec Is Not (Yet)
21
+ ## What SQLSpec Is Not (Yet)
21
22
 
22
23
  SQLSpec is a work in progress. While it offers a solid foundation for modern SQL interactions, it does not yet include every feature you might find in a mature ORM or database toolkit. The focus is on building a robust, flexible core that can be extended over time.
23
24
 
24
- ### Inspiration and Future Direction
25
+ ## Inspiration and Future Direction
25
26
 
26
27
  SQLSpec originally drew inspiration from features found in the `aiosql` library. This is a great library for working with and executed 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.
27
28
 
28
- ### Current Focus: Universal Connectivity
29
+ ## Current Focus: Universal Connectivity
29
30
 
30
31
  The primary goal at this stage is to establish a **native connectivity interface** that works seamlessly across all supported database environments. This means you can connect to any of the supported databases using a consistent API, regardless of the underlying driver or dialect.
31
32
 
32
- ### Adapters: Completed, In Progress, and Planned
33
+ ## Adapters: Completed, In Progress, and Planned
33
34
 
34
35
  This list is not final. If you have a driver you'd like to see added, please open an issue or submit a PR!
35
36
 
@@ -47,13 +48,13 @@ This list is not final. If you have a driver you'd like to see added, please ope
47
48
  | [`oracledb`](https://oracle.github.io/python-oracledb/) | Oracle | Async | ✅ |
48
49
  | [`oracledb`](https://oracle.github.io/python-oracledb/) | Oracle | Sync | ✅ |
49
50
  | [`duckdb`](https://duckdb.org/) | DuckDB | Sync | ✅ |
50
- | [`bigquery`](https://googleapis.dev/python/bigquery/latest/index.html) | BigQuery | Sync | 🗓️ Planned |
51
- | [`spanner`](https://googleapis.dev/python/spanner/latest/index.html) | Spanner | Sync | 🗓️ Planned |
52
- | [`sqlserver`](https://docs.microsoft.com/en-us/sql/connect/python/pyodbc/python-sql-driver-for-pyodbc?view=sql-server-ver16) | SQL Server | Sync | 🗓️ Planned |
53
- | [`mysql`](https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysql-connector-python.html) | MySQL | Sync | 🗓️ Planned |
54
- | [`snowflake`](https://docs.snowflake.com)
51
+ | [`bigquery`](https://googleapis.dev/python/bigquery/latest/index.html) | BigQuery | Sync | 🗓️ |
52
+ | [`spanner`](https://googleapis.dev/python/spanner/latest/index.html) | Spanner | Sync | 🗓️ |
53
+ | [`sqlserver`](https://docs.microsoft.com/en-us/sql/connect/python/pyodbc/python-sql-driver-for-pyodbc?view=sql-server-ver16) | SQL Server | Sync | 🗓️ |
54
+ | [`mysql`](https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysql-connector-python.html) | MySQL | Sync | 🗓️ |
55
+ | [`snowflake`](https://docs.snowflake.com) | Snowflake | Sync | 🗓️ |
55
56
 
56
- ### Proposed Project Structure
57
+ ## Proposed Project Structure
57
58
 
58
59
  - `sqlspec/`:
59
60
  - `adapters/`: Contains all database drivers and associated configuration.
@@ -68,7 +69,7 @@ This list is not final. If you have a driver you'd like to see added, please ope
68
69
  - `exceptions.py`: Contains custom exceptions for SQLSpec.
69
70
  - `typing.py`: Contains type hints, type guards and several facades for optional libraries that are not required for the core functionality of SQLSpec.
70
71
 
71
- ### Get Involved
72
+ ## Get Involved
72
73
 
73
74
  SQLSpec is an open-source project, and contributions are welcome! Whether you're interested in adding support for new databases, improving the query interface, or simply providing feedback, your input is valuable.
74
75
 
@@ -2,11 +2,12 @@
2
2
  authors = [{ name = "Cody Fincher", email = "cody@litestar.dev" }]
3
3
  dependencies = ["typing-extensions", "sqlglot", "eval_type_backport; python_version < \"3.10\""]
4
4
  description = "SQL Experiments in Python"
5
+ license = "MIT"
5
6
  maintainers = [{ name = "Litestar Developers", email = "hello@litestar.dev" }]
6
7
  name = "sqlspec"
7
8
  readme = "README.md"
8
9
  requires-python = ">=3.9, <4.0"
9
- version = "0.5.0"
10
+ version = "0.6.0"
10
11
 
11
12
  [project.optional-dependencies]
12
13
  adbc = ["adbc-driver-manager", "pyarrow"]
@@ -21,7 +22,7 @@ flask = ["flask"]
21
22
  litestar = ["litestar"]
22
23
  msgspec = ["msgspec"]
23
24
  oracledb = ["oracledb"]
24
- performance = ["sqlglot[rs]", "google-re2; sys_platform == \"linux\""]
25
+ performance = ["sqlglot[rs]"]
25
26
  psycopg = ["psycopg[binary,pool]"]
26
27
  pydantic = ["pydantic"]
27
28
  pymssql = ["pymssql"]
@@ -280,66 +281,3 @@ known-first-party = ["sqlspec", "tests"]
280
281
  [tool.ruff.format]
281
282
  docstring-code-format = true
282
283
  docstring-code-line-length = 88
283
-
284
- [tool.git-cliff.changelog]
285
- body = """
286
- {% if version %}\
287
- `Release [v{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} <https://github.com/litestar-org/sqlspec/releases/tag/v{{ version | trim_start_matches(pat="v") }}>`_
288
- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
289
- * `See All commits in v{{ version | trim_start_matches(pat="v") }} <https://github.com/litestar-org/sqlspec/commits/v{{ version | trim_start_matches(pat="v") }}>`_
290
- {% else %}\
291
- [unreleased]
292
- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
293
- {% endif %}\
294
- {% if previous %}\
295
- {% if previous.commit_id %}
296
- `{{ previous.commit_id | truncate(length=7, end="") }} <https://github.com/litestar-org/sqlspec/commit/{{ previous.commit_id }}>`_ ... \
297
- `{{ commit_id | truncate(length=7, end="") }} <https://github.com/litestar-org/sqlspec/commit/{{ commit_id }}>`_ \
298
- | `See diff for {{ version | trim_start_matches(pat="v") }} <https://github.com/litestar-org/sqlspec/compare/{{ previous.commit_id }}...{{ commit_id }}>`_
299
- {% endif %}\
300
- {% endif %}\
301
- {% for group, commits in commits | group_by(attribute="group") %}
302
- {{ group | upper_first }}
303
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
304
- {% for commit in commits %}
305
- * (`{{ commit.id | truncate(length=7, end="") }} <https://github.com/litestar-org/sqlspec/commit/{{ commit.id }}>`_) {% if commit.breaking %}[**breaking**] {% endif %} - {{ commit.message | upper_first }} ({{ commit.author.name }})\
306
- {% for footer in commit.footers -%}
307
- , {{ footer.token }}{{ footer.separator }}{{ footer.value }}\
308
- {% endfor %}\
309
- {% endfor %}
310
- {% endfor %}\n
311
- """
312
- footer = """
313
- Type Lens Changelog
314
- """
315
- header = """
316
- =========
317
- Changelog
318
- =========\n
319
- All commits to this project will be documented in this file.\n
320
- """
321
- trim = true
322
-
323
- [tool.git-cliff.git]
324
- commit_parsers = [
325
- { message = "^feat", group = "Features" },
326
- { message = "^fix", group = "Bug Fixes" },
327
- { message = "^doc", group = "Documentation" },
328
- { message = "^perf", group = "Performance" },
329
- { message = "^refactor", group = "Refactor" },
330
- { message = "^style", group = "Styling" },
331
- { message = "^test", group = "Testing" },
332
- { message = "^chore\\(release\\): prepare for", skip = true },
333
- { message = "^chore", group = "Miscellaneous Tasks" },
334
- { body = ".*security", group = "Security" },
335
- ]
336
- conventional_commits = true
337
- filter_commits = false
338
- filter_unconventional = true
339
- ignore_tags = ""
340
- protect_breaking_commits = false
341
- skip_tags = "v0.1.0-beta.1"
342
- sort_commits = "oldest"
343
- split_commits = false
344
- tag_pattern = "v[0-9]*"
345
- topo_order = false
@@ -4,7 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  from importlib.metadata import PackageNotFoundError, metadata, version
6
6
 
7
- __all__ = ["__project__", "__version__"]
7
+ __all__ = ("__project__", "__version__")
8
8
 
9
9
  try:
10
10
  __version__ = version("sqlspec")
@@ -4,7 +4,7 @@ from contextlib import contextmanager
4
4
  from dataclasses import dataclass
5
5
  from typing import TYPE_CHECKING
6
6
 
7
- from sqlspec.base import GenericDatabaseConfig, NoPoolConfig
7
+ from sqlspec.base import NoPoolSyncConfig
8
8
  from sqlspec.typing import Empty, EmptyType
9
9
 
10
10
  if TYPE_CHECKING:
@@ -17,7 +17,7 @@ __all__ = ("AdbcDatabaseConfig",)
17
17
 
18
18
 
19
19
  @dataclass
20
- class AdbcDatabaseConfig(NoPoolConfig["Connection"], GenericDatabaseConfig):
20
+ class AdbcDatabaseConfig(NoPoolSyncConfig["Connection"]):
21
21
  """Configuration for ADBC connections.
22
22
 
23
23
  This class provides configuration options for ADBC database connections using the
@@ -1,10 +1,10 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from contextlib import asynccontextmanager
4
- from dataclasses import dataclass
4
+ from dataclasses import dataclass, field
5
5
  from typing import TYPE_CHECKING, Any
6
6
 
7
- from sqlspec.base import GenericDatabaseConfig, NoPoolConfig
7
+ from sqlspec.base import NoPoolSyncConfig
8
8
  from sqlspec.exceptions import ImproperConfigurationError
9
9
  from sqlspec.typing import Empty, EmptyType, dataclass_to_dict
10
10
 
@@ -19,7 +19,7 @@ __all__ = ("AiosqliteConfig",)
19
19
 
20
20
 
21
21
  @dataclass
22
- class AiosqliteConfig(NoPoolConfig["Connection"], GenericDatabaseConfig):
22
+ class AiosqliteConfig(NoPoolSyncConfig["Connection"]):
23
23
  """Configuration for Aiosqlite database connections.
24
24
 
25
25
  This class provides configuration options for Aiosqlite database connections, wrapping all parameters
@@ -28,28 +28,21 @@ class AiosqliteConfig(NoPoolConfig["Connection"], GenericDatabaseConfig):
28
28
  For details see: https://github.com/omnilib/aiosqlite/blob/main/aiosqlite/__init__.pyi
29
29
  """
30
30
 
31
- database: str
31
+ database: str = field(default=":memory:")
32
32
  """The path to the database file to be opened. Pass ":memory:" to open a connection to a database that resides in RAM instead of on disk."""
33
-
34
- timeout: float | EmptyType = Empty
33
+ timeout: float | EmptyType = field(default=Empty)
35
34
  """How many seconds the connection should wait before raising an OperationalError when a table is locked. If another thread or process has acquired a shared lock, a wait for the specified timeout occurs."""
36
-
37
- detect_types: int | EmptyType = Empty
35
+ detect_types: int | EmptyType = field(default=Empty)
38
36
  """Control whether and how data types are detected. It can be 0 (default) or a combination of PARSE_DECLTYPES and PARSE_COLNAMES."""
39
-
40
- isolation_level: Literal["DEFERRED", "IMMEDIATE", "EXCLUSIVE"] | None | EmptyType = Empty
37
+ isolation_level: Literal["DEFERRED", "IMMEDIATE", "EXCLUSIVE"] | None | EmptyType = field(default=Empty)
41
38
  """The isolation_level of the connection. This can be None for autocommit mode or one of "DEFERRED", "IMMEDIATE" or "EXCLUSIVE"."""
42
-
43
- check_same_thread: bool | EmptyType = Empty
39
+ check_same_thread: bool | EmptyType = field(default=Empty)
44
40
  """If True (default), ProgrammingError is raised if the database connection is used by a thread other than the one that created it. If False, the connection may be shared across multiple threads."""
45
-
46
- factory: type[SQLite3Connection] | EmptyType = Empty
41
+ factory: type[SQLite3Connection] | EmptyType = field(default=Empty)
47
42
  """A custom Connection class factory. If given, must be a callable that returns a Connection instance."""
48
-
49
- cached_statements: int | EmptyType = Empty
43
+ cached_statements: int | EmptyType = field(default=Empty)
50
44
  """The number of statements that SQLite will cache for this connection. The default is 128."""
51
-
52
- uri: bool | EmptyType = Empty
45
+ uri: bool | EmptyType = field(default=Empty)
53
46
  """If set to True, database is interpreted as a URI with supported options."""
54
47
 
55
48
  @property
@@ -7,7 +7,7 @@ from typing import TYPE_CHECKING, TypeVar
7
7
  from asyncmy.connection import Connection
8
8
  from asyncmy.pool import Pool
9
9
 
10
- from sqlspec.base import DatabaseConfigProtocol, GenericDatabaseConfig, GenericPoolConfig
10
+ from sqlspec.base import AsyncDatabaseConfig, GenericPoolConfig
11
11
  from sqlspec.exceptions import ImproperConfigurationError
12
12
  from sqlspec.typing import Empty, EmptyType, dataclass_to_dict
13
13
 
@@ -106,7 +106,7 @@ class AsyncmyPoolConfig(GenericPoolConfig):
106
106
 
107
107
 
108
108
  @dataclass
109
- class AsyncMyConfig(DatabaseConfigProtocol[Connection, Pool], GenericDatabaseConfig):
109
+ class AsyncMyConfig(AsyncDatabaseConfig[Connection, Pool]):
110
110
  """Asyncmy Configuration."""
111
111
 
112
112
  __is_async__ = True
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from contextlib import asynccontextmanager
4
4
  from dataclasses import dataclass
5
- from typing import TYPE_CHECKING, TypeVar, Union
5
+ from typing import TYPE_CHECKING, Any, TypeVar, Union
6
6
 
7
7
  from asyncpg import Record
8
8
  from asyncpg import create_pool as asyncpg_create_pool
@@ -11,14 +11,13 @@ from asyncpg.pool import Pool, PoolConnectionProxy
11
11
  from typing_extensions import TypeAlias
12
12
 
13
13
  from sqlspec._serialization import decode_json, encode_json
14
- from sqlspec.base import DatabaseConfigProtocol, GenericDatabaseConfig, GenericPoolConfig
14
+ from sqlspec.base import AsyncDatabaseConfig, GenericPoolConfig
15
15
  from sqlspec.exceptions import ImproperConfigurationError
16
16
  from sqlspec.typing import Empty, EmptyType, dataclass_to_dict
17
17
 
18
18
  if TYPE_CHECKING:
19
- from asyncio import AbstractEventLoop
19
+ from asyncio import AbstractEventLoop # pyright: ignore[reportAttributeAccessIssue]
20
20
  from collections.abc import AsyncGenerator, Awaitable, Callable, Coroutine
21
- from typing import Any
22
21
 
23
22
 
24
23
  __all__ = (
@@ -73,12 +72,9 @@ class AsyncPgPoolConfig(GenericPoolConfig):
73
72
 
74
73
 
75
74
  @dataclass
76
- class AsyncPgConfig(DatabaseConfigProtocol[PgConnection, Pool], GenericDatabaseConfig):
75
+ class AsyncPgConfig(AsyncDatabaseConfig[PgConnection, Pool]):
77
76
  """Asyncpg Configuration."""
78
77
 
79
- __is_async__ = True
80
- __supports_connection_pooling__ = True
81
-
82
78
  pool_config: AsyncPgPoolConfig | None = None
83
79
  """Asyncpg Pool configuration"""
84
80
  json_deserializer: Callable[[str], Any] = decode_json
@@ -6,7 +6,7 @@ from typing import TYPE_CHECKING, Any, cast
6
6
 
7
7
  from duckdb import DuckDBPyConnection
8
8
 
9
- from sqlspec.base import GenericDatabaseConfig, NoPoolConfig
9
+ from sqlspec.base import NoPoolSyncConfig
10
10
  from sqlspec.exceptions import ImproperConfigurationError
11
11
  from sqlspec.typing import Empty, EmptyType, dataclass_to_dict
12
12
 
@@ -66,7 +66,7 @@ class ExtensionConfig:
66
66
 
67
67
 
68
68
  @dataclass
69
- class DuckDBConfig(NoPoolConfig[DuckDBPyConnection], GenericDatabaseConfig):
69
+ class DuckDBConfig(NoPoolSyncConfig[DuckDBPyConnection]):
70
70
  """Configuration for DuckDB database connections.
71
71
 
72
72
  This class provides configuration options for DuckDB database connections, wrapping all parameters
@@ -4,14 +4,14 @@ from contextlib import asynccontextmanager
4
4
  from dataclasses import dataclass
5
5
  from typing import TYPE_CHECKING
6
6
 
7
- from oracledb import create_pool_async as oracledb_create_pool
7
+ from oracledb import create_pool_async as oracledb_create_pool # pyright: ignore[reportUnknownVariableType]
8
8
  from oracledb.connection import AsyncConnection
9
9
  from oracledb.pool import AsyncConnectionPool
10
10
 
11
11
  from sqlspec.adapters.oracledb.config._common import (
12
- OracleGenericDatabaseConfig,
13
12
  OracleGenericPoolConfig,
14
13
  )
14
+ from sqlspec.base import AsyncDatabaseConfig
15
15
  from sqlspec.exceptions import ImproperConfigurationError
16
16
  from sqlspec.typing import dataclass_to_dict
17
17
 
@@ -31,11 +31,18 @@ class OracleAsyncPoolConfig(OracleGenericPoolConfig[AsyncConnection, AsyncConnec
31
31
 
32
32
 
33
33
  @dataclass
34
- class OracleAsyncDatabaseConfig(OracleGenericDatabaseConfig[AsyncConnection, AsyncConnectionPool]):
35
- """Async Oracle database Configuration."""
34
+ class OracleAsyncDatabaseConfig(AsyncDatabaseConfig[AsyncConnection, AsyncConnectionPool]):
35
+ """Oracle Async database Configuration.
36
36
 
37
- __is_async__ = True
38
- __supports_connection_pooling__ = True
37
+ This class provides the base configuration for Oracle database connections, extending
38
+ the generic database configuration with Oracle-specific settings. It supports both
39
+ thin and thick modes of the python-oracledb driver.([1](https://python-oracledb.readthedocs.io/en/latest/index.html))
40
+
41
+ The configuration supports all standard Oracle connection parameters and can be used
42
+ with both synchronous and asynchronous connections. It includes support for features
43
+ like Oracle Wallet, external authentication, connection pooling, and advanced security
44
+ options.([2](https://python-oracledb.readthedocs.io/en/latest/user_guide/tuning.html))
45
+ """
39
46
 
40
47
  pool_config: OracleAsyncPoolConfig | None = None
41
48
  """Oracle Pool configuration"""
@@ -94,5 +101,5 @@ class OracleAsyncDatabaseConfig(OracleGenericDatabaseConfig[AsyncConnection, Asy
94
101
  A connection instance.
95
102
  """
96
103
  db_pool = await self.provide_pool(*args, **kwargs)
97
- async with db_pool.acquire() as connection:
104
+ async with db_pool.acquire() as connection: # pyright: ignore[reportUnknownMemberType]
98
105
  yield connection
@@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Generic, TypeVar
5
5
 
6
6
  from oracledb import ConnectionPool
7
7
 
8
- from sqlspec.base import DatabaseConfigProtocol, GenericDatabaseConfig, GenericPoolConfig
8
+ from sqlspec.base import GenericPoolConfig
9
9
  from sqlspec.typing import Empty
10
10
 
11
11
  if TYPE_CHECKING:
@@ -19,10 +19,7 @@ if TYPE_CHECKING:
19
19
 
20
20
  from sqlspec.typing import EmptyType
21
21
 
22
- __all__ = (
23
- "OracleGenericDatabaseConfig",
24
- "OracleGenericPoolConfig",
25
- )
22
+ __all__ = ("OracleGenericPoolConfig",)
26
23
 
27
24
 
28
25
  T = TypeVar("T")
@@ -134,18 +131,3 @@ class OracleGenericPoolConfig(Generic[ConnectionT, PoolT], GenericPoolConfig):
134
131
  """SSL/TLS protocol version"""
135
132
  handle: int | EmptyType = Empty
136
133
  """Oracle service context handle"""
137
-
138
-
139
- @dataclass
140
- class OracleGenericDatabaseConfig(DatabaseConfigProtocol[ConnectionT, PoolT], GenericDatabaseConfig):
141
- """Oracle database Configuration.
142
-
143
- This class provides the base configuration for Oracle database connections, extending
144
- the generic database configuration with Oracle-specific settings. It supports both
145
- thin and thick modes of the python-oracledb driver.([1](https://python-oracledb.readthedocs.io/en/latest/index.html))
146
-
147
- The configuration supports all standard Oracle connection parameters and can be used
148
- with both synchronous and asynchronous connections. It includes support for features
149
- like Oracle Wallet, external authentication, connection pooling, and advanced security
150
- options.([2](https://python-oracledb.readthedocs.io/en/latest/user_guide/tuning.html))
151
- """
@@ -4,14 +4,14 @@ from contextlib import contextmanager
4
4
  from dataclasses import dataclass
5
5
  from typing import TYPE_CHECKING
6
6
 
7
- from oracledb import create_pool as oracledb_create_pool
7
+ from oracledb import create_pool as oracledb_create_pool # pyright: ignore[reportUnknownVariableType]
8
8
  from oracledb.connection import Connection
9
9
  from oracledb.pool import ConnectionPool
10
10
 
11
11
  from sqlspec.adapters.oracledb.config._common import (
12
- OracleGenericDatabaseConfig,
13
12
  OracleGenericPoolConfig,
14
13
  )
14
+ from sqlspec.base import SyncDatabaseConfig
15
15
  from sqlspec.exceptions import ImproperConfigurationError
16
16
  from sqlspec.typing import dataclass_to_dict
17
17
 
@@ -31,11 +31,18 @@ class OracleSyncPoolConfig(OracleGenericPoolConfig[Connection, ConnectionPool]):
31
31
 
32
32
 
33
33
  @dataclass
34
- class OracleSyncDatabaseConfig(OracleGenericDatabaseConfig[Connection, ConnectionPool]):
35
- """Oracle database Configuration."""
34
+ class OracleSyncDatabaseConfig(SyncDatabaseConfig[Connection, ConnectionPool]):
35
+ """Oracle Sync database Configuration.
36
36
 
37
- __is_async__ = False
38
- __supports_connection_pooling__ = True
37
+ This class provides the base configuration for Oracle database connections, extending
38
+ the generic database configuration with Oracle-specific settings. It supports both
39
+ thin and thick modes of the python-oracledb driver.([1](https://python-oracledb.readthedocs.io/en/latest/index.html))
40
+
41
+ The configuration supports all standard Oracle connection parameters and can be used
42
+ with both synchronous and asynchronous connections. It includes support for features
43
+ like Oracle Wallet, external authentication, connection pooling, and advanced security
44
+ options.([2](https://python-oracledb.readthedocs.io/en/latest/user_guide/tuning.html))
45
+ """
39
46
 
40
47
  pool_config: OracleSyncPoolConfig | None = None
41
48
  """Oracle Pool configuration"""
@@ -7,10 +7,8 @@ from typing import TYPE_CHECKING
7
7
  from psycopg import AsyncConnection
8
8
  from psycopg_pool import AsyncConnectionPool
9
9
 
10
- from sqlspec.adapters.psycopg.config._common import (
11
- PsycoPgGenericDatabaseConfig,
12
- PsycoPgGenericPoolConfig,
13
- )
10
+ from sqlspec.adapters.psycopg.config._common import PsycoPgGenericPoolConfig
11
+ from sqlspec.base import AsyncDatabaseConfig
14
12
  from sqlspec.exceptions import ImproperConfigurationError
15
13
  from sqlspec.typing import dataclass_to_dict
16
14
 
@@ -31,11 +29,15 @@ class PsycoPgAsyncPoolConfig(PsycoPgGenericPoolConfig[AsyncConnection, AsyncConn
31
29
 
32
30
 
33
31
  @dataclass
34
- class PsycoPgAsyncDatabaseConfig(PsycoPgGenericDatabaseConfig[AsyncConnection, AsyncConnectionPool]):
35
- """Async Psycopg database Configuration."""
32
+ class PsycoPgAsyncDatabaseConfig(AsyncDatabaseConfig[AsyncConnection, AsyncConnectionPool]):
33
+ """Async Psycopg database Configuration.
34
+
35
+ This class provides the base configuration for Psycopg database connections, extending
36
+ the generic database configuration with Psycopg-specific settings.([1](https://www.psycopg.org/psycopg3/docs/api/connections.html))
36
37
 
37
- __is_async__ = True
38
- __supports_connection_pooling__ = True
38
+ The configuration supports all standard Psycopg connection parameters and can be used
39
+ with both synchronous and asynchronous connections.([2](https://www.psycopg.org/psycopg3/docs/api/connections.html))
40
+ """
39
41
 
40
42
  pool_config: PsycoPgAsyncPoolConfig | None = None
41
43
  """Psycopg Pool configuration"""