datus-postgresql 0.1.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.
- datus_postgresql-0.1.0/.gitignore +137 -0
- datus_postgresql-0.1.0/PKG-INFO +81 -0
- datus_postgresql-0.1.0/README.md +59 -0
- datus_postgresql-0.1.0/datus_postgresql/__init__.py +16 -0
- datus_postgresql-0.1.0/datus_postgresql/config.py +24 -0
- datus_postgresql-0.1.0/datus_postgresql/connector.py +530 -0
- datus_postgresql-0.1.0/docker-compose.yml +23 -0
- datus_postgresql-0.1.0/pyproject.toml +69 -0
- datus_postgresql-0.1.0/tests/__init__.py +3 -0
- datus_postgresql-0.1.0/tests/conftest.py +10 -0
- datus_postgresql-0.1.0/tests/integration/__init__.py +3 -0
- datus_postgresql-0.1.0/tests/integration/conftest.py +41 -0
- datus_postgresql-0.1.0/tests/integration/test_integration.py +423 -0
- datus_postgresql-0.1.0/tests/unit/__init__.py +3 -0
- datus_postgresql-0.1.0/tests/unit/test_config.py +247 -0
- datus_postgresql-0.1.0/tests/unit/test_connector_unit.py +392 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
pip-wheel-metadata/
|
|
24
|
+
share/python-wheels/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
.installed.cfg
|
|
27
|
+
*.egg
|
|
28
|
+
MANIFEST
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
*.manifest
|
|
32
|
+
*.spec
|
|
33
|
+
|
|
34
|
+
# Installer logs
|
|
35
|
+
pip-log.txt
|
|
36
|
+
pip-delete-this-directory.txt
|
|
37
|
+
|
|
38
|
+
# Unit test / coverage reports
|
|
39
|
+
htmlcov/
|
|
40
|
+
.tox/
|
|
41
|
+
.nox/
|
|
42
|
+
.coverage
|
|
43
|
+
.coverage.*
|
|
44
|
+
.cache
|
|
45
|
+
nosetests.xml
|
|
46
|
+
coverage.xml
|
|
47
|
+
*.cover
|
|
48
|
+
*.py,cover
|
|
49
|
+
.hypothesis/
|
|
50
|
+
.pytest_cache/
|
|
51
|
+
|
|
52
|
+
# Translations
|
|
53
|
+
*.mo
|
|
54
|
+
*.pot
|
|
55
|
+
|
|
56
|
+
# Django stuff:
|
|
57
|
+
*.log
|
|
58
|
+
local_settings.py
|
|
59
|
+
db.sqlite3
|
|
60
|
+
db.sqlite3-journal
|
|
61
|
+
|
|
62
|
+
# Flask stuff:
|
|
63
|
+
instance/
|
|
64
|
+
.webassets-cache
|
|
65
|
+
|
|
66
|
+
# Scrapy stuff:
|
|
67
|
+
.scrapy
|
|
68
|
+
|
|
69
|
+
# Sphinx documentation
|
|
70
|
+
docs/_build/
|
|
71
|
+
|
|
72
|
+
# PyBuilder
|
|
73
|
+
target/
|
|
74
|
+
|
|
75
|
+
# Jupyter Notebook
|
|
76
|
+
.ipynb_checkpoints
|
|
77
|
+
|
|
78
|
+
# IPython
|
|
79
|
+
profile_default/
|
|
80
|
+
ipython_config.py
|
|
81
|
+
|
|
82
|
+
# pyenv
|
|
83
|
+
.python-version
|
|
84
|
+
|
|
85
|
+
# pipenv
|
|
86
|
+
Pipfile.lock
|
|
87
|
+
|
|
88
|
+
# uv
|
|
89
|
+
uv.lock
|
|
90
|
+
|
|
91
|
+
# PEP 582
|
|
92
|
+
__pypackages__/
|
|
93
|
+
|
|
94
|
+
# Celery stuff
|
|
95
|
+
celerybeat-schedule
|
|
96
|
+
celerybeat.pid
|
|
97
|
+
|
|
98
|
+
# SageMath parsed files
|
|
99
|
+
*.sage.py
|
|
100
|
+
|
|
101
|
+
# Environments
|
|
102
|
+
.env
|
|
103
|
+
.venv
|
|
104
|
+
env/
|
|
105
|
+
venv/
|
|
106
|
+
ENV/
|
|
107
|
+
env.bak/
|
|
108
|
+
venv.bak/
|
|
109
|
+
|
|
110
|
+
# Spyder project settings
|
|
111
|
+
.spyderproject
|
|
112
|
+
.spyproject
|
|
113
|
+
|
|
114
|
+
# Rope project settings
|
|
115
|
+
.ropeproject
|
|
116
|
+
|
|
117
|
+
# mkdocs documentation
|
|
118
|
+
/site
|
|
119
|
+
|
|
120
|
+
# mypy
|
|
121
|
+
.mypy_cache/
|
|
122
|
+
.dmypy.json
|
|
123
|
+
dmypy.json
|
|
124
|
+
|
|
125
|
+
# Pyre type checker
|
|
126
|
+
.pyre/
|
|
127
|
+
|
|
128
|
+
# IDEs
|
|
129
|
+
.vscode/
|
|
130
|
+
.idea/
|
|
131
|
+
*.swp
|
|
132
|
+
*.swo
|
|
133
|
+
*~
|
|
134
|
+
|
|
135
|
+
# OS
|
|
136
|
+
.DS_Store
|
|
137
|
+
Thumbs.db
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: datus-postgresql
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: PostgreSQL database adapter for Datus
|
|
5
|
+
Project-URL: Homepage, https://github.com/Datus-ai/datus-db-adapters
|
|
6
|
+
Project-URL: Repository, https://github.com/Datus-ai/datus-db-adapters
|
|
7
|
+
Project-URL: Issues, https://github.com/Datus-ai/datus-db-adapters/issues
|
|
8
|
+
Author-email: DatusAI <support@datus.ai>
|
|
9
|
+
License: Apache-2.0
|
|
10
|
+
Keywords: adapter,database,datus,postgresql
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Requires-Python: >=3.12
|
|
17
|
+
Requires-Dist: datus-agent>0.2.1
|
|
18
|
+
Requires-Dist: datus-sqlalchemy>=0.1.2
|
|
19
|
+
Requires-Dist: psycopg2-binary>=2.9.11
|
|
20
|
+
Requires-Dist: pydantic>=2.0.0
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# datus-postgresql
|
|
24
|
+
|
|
25
|
+
PostgreSQL database adapter for Datus.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install datus-postgresql
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from datus_postgresql import PostgreSQLConnector, PostgreSQLConfig
|
|
37
|
+
|
|
38
|
+
# Using config object
|
|
39
|
+
config = PostgreSQLConfig(
|
|
40
|
+
host="localhost",
|
|
41
|
+
port=5432,
|
|
42
|
+
username="postgres",
|
|
43
|
+
password="password",
|
|
44
|
+
database="mydb",
|
|
45
|
+
schema_name="public",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
connector = PostgreSQLConnector(config)
|
|
49
|
+
|
|
50
|
+
# Or using dict
|
|
51
|
+
connector = PostgreSQLConnector({
|
|
52
|
+
"host": "localhost",
|
|
53
|
+
"port": 5432,
|
|
54
|
+
"username": "postgres",
|
|
55
|
+
"password": "password",
|
|
56
|
+
"database": "mydb",
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
# Test connection
|
|
60
|
+
connector.test_connection()
|
|
61
|
+
|
|
62
|
+
# Execute queries
|
|
63
|
+
result = connector.execute({"sql_query": "SELECT * FROM users"})
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Configuration Options
|
|
67
|
+
|
|
68
|
+
| Option | Type | Default | Description |
|
|
69
|
+
|--------|------|---------|-------------|
|
|
70
|
+
| host | str | "127.0.0.1" | PostgreSQL server host |
|
|
71
|
+
| port | int | 5432 | PostgreSQL server port |
|
|
72
|
+
| username | str | required | PostgreSQL username |
|
|
73
|
+
| password | str | "" | PostgreSQL password |
|
|
74
|
+
| database | str | None | Default database name |
|
|
75
|
+
| schema | str | "public" | Default schema name |
|
|
76
|
+
| sslmode | str | "prefer" | SSL mode |
|
|
77
|
+
| timeout_seconds | int | 30 | Connection timeout |
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
Apache-2.0
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# datus-postgresql
|
|
2
|
+
|
|
3
|
+
PostgreSQL database adapter for Datus.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install datus-postgresql
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from datus_postgresql import PostgreSQLConnector, PostgreSQLConfig
|
|
15
|
+
|
|
16
|
+
# Using config object
|
|
17
|
+
config = PostgreSQLConfig(
|
|
18
|
+
host="localhost",
|
|
19
|
+
port=5432,
|
|
20
|
+
username="postgres",
|
|
21
|
+
password="password",
|
|
22
|
+
database="mydb",
|
|
23
|
+
schema_name="public",
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
connector = PostgreSQLConnector(config)
|
|
27
|
+
|
|
28
|
+
# Or using dict
|
|
29
|
+
connector = PostgreSQLConnector({
|
|
30
|
+
"host": "localhost",
|
|
31
|
+
"port": 5432,
|
|
32
|
+
"username": "postgres",
|
|
33
|
+
"password": "password",
|
|
34
|
+
"database": "mydb",
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
# Test connection
|
|
38
|
+
connector.test_connection()
|
|
39
|
+
|
|
40
|
+
# Execute queries
|
|
41
|
+
result = connector.execute({"sql_query": "SELECT * FROM users"})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Configuration Options
|
|
45
|
+
|
|
46
|
+
| Option | Type | Default | Description |
|
|
47
|
+
|--------|------|---------|-------------|
|
|
48
|
+
| host | str | "127.0.0.1" | PostgreSQL server host |
|
|
49
|
+
| port | int | 5432 | PostgreSQL server port |
|
|
50
|
+
| username | str | required | PostgreSQL username |
|
|
51
|
+
| password | str | "" | PostgreSQL password |
|
|
52
|
+
| database | str | None | Default database name |
|
|
53
|
+
| schema | str | "public" | Default schema name |
|
|
54
|
+
| sslmode | str | "prefer" | SSL mode |
|
|
55
|
+
| timeout_seconds | int | 30 | Connection timeout |
|
|
56
|
+
|
|
57
|
+
## License
|
|
58
|
+
|
|
59
|
+
Apache-2.0
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Copyright 2025-present DatusAI, Inc.
|
|
2
|
+
# Licensed under the Apache License, Version 2.0.
|
|
3
|
+
# See http://www.apache.org/licenses/LICENSE-2.0 for details.
|
|
4
|
+
|
|
5
|
+
from .config import PostgreSQLConfig
|
|
6
|
+
from .connector import PostgreSQLConnector
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.0"
|
|
9
|
+
__all__ = ["PostgreSQLConnector", "PostgreSQLConfig", "register"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def register():
|
|
13
|
+
"""Register PostgreSQL connector with Datus registry."""
|
|
14
|
+
from datus.tools.db_tools import connector_registry
|
|
15
|
+
|
|
16
|
+
connector_registry.register("postgresql", PostgreSQLConnector, config_class=PostgreSQLConfig)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Copyright 2025-present DatusAI, Inc.
|
|
2
|
+
# Licensed under the Apache License, Version 2.0.
|
|
3
|
+
# See http://www.apache.org/licenses/LICENSE-2.0 for details.
|
|
4
|
+
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PostgreSQLConfig(BaseModel):
|
|
11
|
+
"""PostgreSQL-specific configuration."""
|
|
12
|
+
|
|
13
|
+
model_config = ConfigDict(extra="forbid", populate_by_name=True)
|
|
14
|
+
|
|
15
|
+
host: str = Field(default="127.0.0.1", description="PostgreSQL server host")
|
|
16
|
+
port: int = Field(default=5432, description="PostgreSQL server port")
|
|
17
|
+
username: str = Field(..., description="PostgreSQL username")
|
|
18
|
+
password: str = Field(default="", description="PostgreSQL password", json_schema_extra={"input_type": "password"})
|
|
19
|
+
database: Optional[str] = Field(default=None, description="Default database name")
|
|
20
|
+
schema_name: Optional[str] = Field(default="public", alias="schema", description="Default schema name")
|
|
21
|
+
sslmode: str = Field(
|
|
22
|
+
default="prefer", description="SSL mode (disable, allow, prefer, require, verify-ca, verify-full)"
|
|
23
|
+
)
|
|
24
|
+
timeout_seconds: int = Field(default=30, description="Connection timeout in seconds")
|