nl2sql-adapter-sdk 0.1.2__tar.gz → 0.2.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.
- nl2sql_adapter_sdk-0.2.0/PKG-INFO +48 -0
- nl2sql_adapter_sdk-0.2.0/README.md +25 -0
- nl2sql_adapter_sdk-0.2.0/pyproject.toml +41 -0
- {nl2sql_adapter_sdk-0.1.2 → nl2sql_adapter_sdk-0.2.0}/src/nl2sql_adapter_sdk/__init__.py +2 -1
- nl2sql_adapter_sdk-0.2.0/src/nl2sql_adapter_sdk/capabilities.py +8 -0
- {nl2sql_adapter_sdk-0.1.2 → nl2sql_adapter_sdk-0.2.0}/src/nl2sql_adapter_sdk/protocols.py +24 -1
- nl2sql_adapter_sdk-0.2.0/src/nl2sql_adapter_sdk.egg-info/PKG-INFO +48 -0
- {nl2sql_adapter_sdk-0.1.2 → nl2sql_adapter_sdk-0.2.0}/src/nl2sql_adapter_sdk.egg-info/SOURCES.txt +1 -0
- nl2sql_adapter_sdk-0.2.0/src/nl2sql_adapter_sdk.egg-info/requires.txt +1 -0
- nl2sql_adapter_sdk-0.1.2/PKG-INFO +0 -6
- nl2sql_adapter_sdk-0.1.2/pyproject.toml +0 -19
- nl2sql_adapter_sdk-0.1.2/src/nl2sql_adapter_sdk/capabilities.py +0 -13
- nl2sql_adapter_sdk-0.1.2/src/nl2sql_adapter_sdk.egg-info/PKG-INFO +0 -6
- nl2sql_adapter_sdk-0.1.2/src/nl2sql_adapter_sdk.egg-info/requires.txt +0 -1
- {nl2sql_adapter_sdk-0.1.2 → nl2sql_adapter_sdk-0.2.0}/setup.cfg +0 -0
- {nl2sql_adapter_sdk-0.1.2 → nl2sql_adapter_sdk-0.2.0}/src/nl2sql_adapter_sdk/contracts.py +0 -0
- {nl2sql_adapter_sdk-0.1.2 → nl2sql_adapter_sdk-0.2.0}/src/nl2sql_adapter_sdk/schema.py +0 -0
- {nl2sql_adapter_sdk-0.1.2 → nl2sql_adapter_sdk-0.2.0}/src/nl2sql_adapter_sdk.egg-info/dependency_links.txt +0 -0
- {nl2sql_adapter_sdk-0.1.2 → nl2sql_adapter_sdk-0.2.0}/src/nl2sql_adapter_sdk.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nl2sql-adapter-sdk
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: The contracts a database adapter for the nl2sql engine implements; depends on pydantic only
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/nadeem4/nl2sql
|
|
7
|
+
Project-URL: Documentation, https://nadeem4.github.io/nl2sql/
|
|
8
|
+
Project-URL: Source, https://github.com/nadeem4/nl2sql
|
|
9
|
+
Project-URL: Issues, https://github.com/nadeem4/nl2sql/issues
|
|
10
|
+
Project-URL: Demo, https://nadeem4nk-nl2sql-demo.hf.space
|
|
11
|
+
Keywords: nl2sql,text-to-sql,sql,database,adapter,sdk
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Database
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Requires-Python: >=3.12
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: pydantic>=2.0
|
|
23
|
+
|
|
24
|
+
# nl2sql-adapter-sdk
|
|
25
|
+
|
|
26
|
+
The contracts a database adapter for the
|
|
27
|
+
[nl2sql engine](https://github.com/nadeem4/nl2sql) implements. It depends on
|
|
28
|
+
pydantic and the standard library only, so an adapter built against it inherits
|
|
29
|
+
nothing else.
|
|
30
|
+
|
|
31
|
+
- `DatasourceAdapterProtocol`: `capabilities()`, `connect()`,
|
|
32
|
+
`fetch_schema_snapshot()`, `execute(request)` and `get_dialect()`, which
|
|
33
|
+
returns a sqlglot dialect name such as `postgres` or `tsql`.
|
|
34
|
+
- `AdapterRequest`, `ResultFrame` and `ResultError`: what the engine sends an
|
|
35
|
+
adapter and what it gets back.
|
|
36
|
+
- `SchemaSnapshot` and the table, column and foreign-key contracts an adapter
|
|
37
|
+
describes its schema with.
|
|
38
|
+
|
|
39
|
+
An adapter is published as an `nl2sql.adapters` entry point, and the engine
|
|
40
|
+
finds it there; it never imports an adapter by name.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install nl2sql-adapter-sdk
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Writing an adapter:
|
|
47
|
+
[Adapter development](https://nadeem4.github.io/nl2sql/adapters/development/).
|
|
48
|
+
Try the engine without installing anything: <https://nadeem4nk-nl2sql-demo.hf.space>.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# nl2sql-adapter-sdk
|
|
2
|
+
|
|
3
|
+
The contracts a database adapter for the
|
|
4
|
+
[nl2sql engine](https://github.com/nadeem4/nl2sql) implements. It depends on
|
|
5
|
+
pydantic and the standard library only, so an adapter built against it inherits
|
|
6
|
+
nothing else.
|
|
7
|
+
|
|
8
|
+
- `DatasourceAdapterProtocol`: `capabilities()`, `connect()`,
|
|
9
|
+
`fetch_schema_snapshot()`, `execute(request)` and `get_dialect()`, which
|
|
10
|
+
returns a sqlglot dialect name such as `postgres` or `tsql`.
|
|
11
|
+
- `AdapterRequest`, `ResultFrame` and `ResultError`: what the engine sends an
|
|
12
|
+
adapter and what it gets back.
|
|
13
|
+
- `SchemaSnapshot` and the table, column and foreign-key contracts an adapter
|
|
14
|
+
describes its schema with.
|
|
15
|
+
|
|
16
|
+
An adapter is published as an `nl2sql.adapters` entry point, and the engine
|
|
17
|
+
finds it there; it never imports an adapter by name.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install nl2sql-adapter-sdk
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Writing an adapter:
|
|
24
|
+
[Adapter development](https://nadeem4.github.io/nl2sql/adapters/development/).
|
|
25
|
+
Try the engine without installing anything: <https://nadeem4nk-nl2sql-demo.hf.space>.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "nl2sql-adapter-sdk"
|
|
7
|
+
version = "0.2.0" # x-release-please-version
|
|
8
|
+
description = "The contracts a database adapter for the nl2sql engine implements; depends on pydantic only"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
keywords = ["nl2sql", "text-to-sql", "sql", "database", "adapter", "sdk"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 3 - Alpha",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"Operating System :: OS Independent",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
18
|
+
"Programming Language :: Python :: 3.13",
|
|
19
|
+
"Topic :: Database",
|
|
20
|
+
"Topic :: Software Development :: Libraries",
|
|
21
|
+
]
|
|
22
|
+
requires-python = ">=3.12"
|
|
23
|
+
dependencies = [
|
|
24
|
+
# ConfigDict (contracts.py, schema.py) is pydantic v2 only; the old
|
|
25
|
+
# >=1.10 floor advertised an install that cannot import.
|
|
26
|
+
"pydantic>=2.0",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://github.com/nadeem4/nl2sql"
|
|
31
|
+
Documentation = "https://nadeem4.github.io/nl2sql/"
|
|
32
|
+
Source = "https://github.com/nadeem4/nl2sql"
|
|
33
|
+
Issues = "https://github.com/nadeem4/nl2sql/issues"
|
|
34
|
+
Demo = "https://nadeem4nk-nl2sql-demo.hf.space"
|
|
35
|
+
|
|
36
|
+
[tool.setuptools]
|
|
37
|
+
package-dir = {"" = "src"}
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.packages.find]
|
|
40
|
+
where = ["src"]
|
|
41
|
+
include = ["nl2sql_adapter_sdk*"]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from .capabilities import DatasourceCapability
|
|
4
4
|
from .contracts import AdapterRequest, ResultError, ResultFrame
|
|
5
|
-
from .protocols import DatasourceAdapterProtocol
|
|
5
|
+
from .protocols import DatasourceAdapterProtocol, SqlRenderingAdapterProtocol
|
|
6
6
|
from .schema import (
|
|
7
7
|
TableRef,
|
|
8
8
|
ColumnStatistics,
|
|
@@ -23,6 +23,7 @@ __all__ = [
|
|
|
23
23
|
"ResultError",
|
|
24
24
|
"ResultFrame",
|
|
25
25
|
"DatasourceAdapterProtocol",
|
|
26
|
+
"SqlRenderingAdapterProtocol",
|
|
26
27
|
"TableRef",
|
|
27
28
|
"ColumnStatistics",
|
|
28
29
|
"ColumnMetadata",
|
|
@@ -32,10 +32,33 @@ class DatasourceAdapterProtocol(Protocol):
|
|
|
32
32
|
...
|
|
33
33
|
|
|
34
34
|
def get_dialect(self) -> str:
|
|
35
|
-
"""Return the
|
|
35
|
+
"""Return the sqlglot dialect name the engine renders SQL in (SQL adapters).
|
|
36
|
+
|
|
37
|
+
It must be a name ``sqlglot.Dialect.get_or_raise`` accepts, such as
|
|
38
|
+
``postgres``, ``tsql``, ``mysql``, ``duckdb`` or ``sqlite``, not the
|
|
39
|
+
SQLAlchemy dialect name (``postgresql``, ``mssql``).
|
|
40
|
+
"""
|
|
36
41
|
...
|
|
37
42
|
|
|
38
43
|
|
|
39
44
|
def test_connection(self) -> bool:
|
|
40
45
|
"""Test if the connection to the datasource can be established."""
|
|
41
46
|
...
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@runtime_checkable
|
|
50
|
+
class SqlRenderingAdapterProtocol(Protocol):
|
|
51
|
+
"""Optional hook: render the engine's finished SQL for this database.
|
|
52
|
+
|
|
53
|
+
The engine builds each query as a sqlglot expression tree and, when the
|
|
54
|
+
adapter has ``render_sql``, hands it the tree to render. Without the hook
|
|
55
|
+
the engine renders ``expression.sql(dialect=adapter.get_dialect())``, so
|
|
56
|
+
existing adapters keep working. Override it only to rewrite what sqlglot
|
|
57
|
+
cannot express for the database, and keep the result types every adapter
|
|
58
|
+
returns: a date part (``DATE_PART``) is an INTEGER, and a truncated date
|
|
59
|
+
(``DATE_TRUNC``) is an ISO date string ``YYYY-MM-DD``.
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
def render_sql(self, expression: Any) -> str:
|
|
63
|
+
"""Return the SQL text for ``expression`` (a ``sqlglot.exp.Expression``)."""
|
|
64
|
+
...
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nl2sql-adapter-sdk
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: The contracts a database adapter for the nl2sql engine implements; depends on pydantic only
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/nadeem4/nl2sql
|
|
7
|
+
Project-URL: Documentation, https://nadeem4.github.io/nl2sql/
|
|
8
|
+
Project-URL: Source, https://github.com/nadeem4/nl2sql
|
|
9
|
+
Project-URL: Issues, https://github.com/nadeem4/nl2sql/issues
|
|
10
|
+
Project-URL: Demo, https://nadeem4nk-nl2sql-demo.hf.space
|
|
11
|
+
Keywords: nl2sql,text-to-sql,sql,database,adapter,sdk
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Database
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Requires-Python: >=3.12
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: pydantic>=2.0
|
|
23
|
+
|
|
24
|
+
# nl2sql-adapter-sdk
|
|
25
|
+
|
|
26
|
+
The contracts a database adapter for the
|
|
27
|
+
[nl2sql engine](https://github.com/nadeem4/nl2sql) implements. It depends on
|
|
28
|
+
pydantic and the standard library only, so an adapter built against it inherits
|
|
29
|
+
nothing else.
|
|
30
|
+
|
|
31
|
+
- `DatasourceAdapterProtocol`: `capabilities()`, `connect()`,
|
|
32
|
+
`fetch_schema_snapshot()`, `execute(request)` and `get_dialect()`, which
|
|
33
|
+
returns a sqlglot dialect name such as `postgres` or `tsql`.
|
|
34
|
+
- `AdapterRequest`, `ResultFrame` and `ResultError`: what the engine sends an
|
|
35
|
+
adapter and what it gets back.
|
|
36
|
+
- `SchemaSnapshot` and the table, column and foreign-key contracts an adapter
|
|
37
|
+
describes its schema with.
|
|
38
|
+
|
|
39
|
+
An adapter is published as an `nl2sql.adapters` entry point, and the engine
|
|
40
|
+
finds it there; it never imports an adapter by name.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install nl2sql-adapter-sdk
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Writing an adapter:
|
|
47
|
+
[Adapter development](https://nadeem4.github.io/nl2sql/adapters/development/).
|
|
48
|
+
Try the engine without installing anything: <https://nadeem4nk-nl2sql-demo.hf.space>.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pydantic>=2.0
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=64", "wheel"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "nl2sql-adapter-sdk"
|
|
7
|
-
version = "0.1.2" # x-release-please-version
|
|
8
|
-
description = "Shared adapter contracts for NL2SQL"
|
|
9
|
-
requires-python = ">=3.9"
|
|
10
|
-
dependencies = [
|
|
11
|
-
"pydantic>=1.10",
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
[tool.setuptools]
|
|
15
|
-
package-dir = {"" = "src"}
|
|
16
|
-
|
|
17
|
-
[tool.setuptools.packages.find]
|
|
18
|
-
where = ["src"]
|
|
19
|
-
include = ["nl2sql_adapter_sdk*"]
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
from enum import Enum
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class DatasourceCapability(str, Enum):
|
|
5
|
-
"""Capability flags for datasource adapters."""
|
|
6
|
-
|
|
7
|
-
SUPPORTS_SQL = "supports_sql"
|
|
8
|
-
SUPPORTS_REST = "supports_rest"
|
|
9
|
-
SUPPORTS_GRAPHQL = "supports_graphql"
|
|
10
|
-
SUPPORTS_LAKE = "supports_lake"
|
|
11
|
-
SUPPORTS_SCHEMA_INTROSPECTION = "supports_schema_introspection"
|
|
12
|
-
SUPPORTS_DRY_RUN = "supports_dry_run"
|
|
13
|
-
SUPPORTS_COST_ESTIMATE = "supports_cost_estimate"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pydantic>=1.10
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nl2sql_adapter_sdk-0.1.2 → nl2sql_adapter_sdk-0.2.0}/src/nl2sql_adapter_sdk.egg-info/top_level.txt
RENAMED
|
File without changes
|