Skip to content

Commit 40f88e7

Browse files
authored
Merge pull request #8 from singlestore-labs/modernize
Modernize the SQLAlchemy dialect. This includes adding many SingleStoreDB-specific features to the SQL reflection parser, support for vector data types, and additional singlestoredb keyword parameters to SQLAlchemy objects for SingleStoreDB-specific options.
2 parents 03912c6 + c635608 commit 40f88e7

36 files changed

+11960
-186
lines changed

.github/workflows/coverage.yml

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,58 +11,54 @@ jobs:
1111
test-coverage:
1212
runs-on: ubuntu-latest
1313

14-
services:
15-
singlestore:
16-
image: ghcr.io/singlestore-labs/singlestoredb-dev:latest
17-
ports:
18-
- 3307:3306
19-
- 8081:8080
20-
- 9080:9080
21-
env:
22-
SINGLESTORE_LICENSE: ${{ secrets.SINGLESTORE_LICENSE }}
23-
ROOT_PASSWORD: "root"
24-
2514
steps:
2615
- uses: actions/checkout@v3
2716

2817
- name: Set up Python
2918
uses: actions/setup-python@v4
3019
with:
31-
python-version: "3.10"
20+
python-version: "3.11"
3221
cache: "pip"
3322

3423
- name: Install dependencies
3524
run: |
3625
python -m pip install --upgrade pip
3726
pip install -e ".[dev]"
3827
39-
- name: Install SingleStore package
28+
- name: Install SingleStore package and SQLAlchemy 2.0.x
4029
run: |
30+
pip install 'sqlalchemy~=2.0.0'
4131
pip install .
4232
4333
- name: Run MySQL protocol tests
4434
run: |
4535
pytest -v --cov=sqlalchemy_singlestoredb --pyargs sqlalchemy_singlestoredb.tests
4636
env:
47-
COVERAGE_FILE: "coverage-mysql.cov"
48-
SINGLESTOREDB_URL: "root:[email protected]:3307"
37+
COVERAGE_FILE: "coverage-mysql-2-0.cov"
4938
SINGLESTOREDB_MANAGEMENT_TOKEN: ${{ secrets.CLUSTER_API_KEY }}
5039

5140
- name: Run HTTP protocol tests
5241
run: |
5342
pytest -v --cov=sqlalchemy_singlestoredb --pyargs sqlalchemy_singlestoredb.tests
5443
env:
5544
COVERAGE_FILE: "coverage-http.cov"
56-
SINGLESTOREDB_URL: "http://root:[email protected]:9080"
5745
SINGLESTOREDB_MANAGEMENT_TOKEN: ${{ secrets.CLUSTER_API_KEY }}
58-
# Can not change databases using HTTP API. The URL below will be
59-
# used to create the database and the generated database name will
60-
# be applied to the above URL.
61-
SINGLESTOREDB_INIT_DB_URL: "root:[email protected]:3307"
46+
USE_DATA_API: "1"
47+
48+
- name: Install SingleStore package and SQLAlchemy 1.4.x
49+
run: |
50+
pip install 'sqlalchemy~=1.4.0'
51+
52+
- name: Run MySQL protocol tests
53+
run: |
54+
pytest -v --cov=sqlalchemy_singlestoredb --pyargs sqlalchemy_singlestoredb.tests
55+
env:
56+
COVERAGE_FILE: "coverage-mysql-1-4.cov"
57+
SINGLESTOREDB_MANAGEMENT_TOKEN: ${{ secrets.CLUSTER_API_KEY }}
6258

6359
- name: Generate report
6460
run: |
65-
coverage combine coverage-mysql.cov coverage-http.cov
61+
coverage combine coverage-mysql-2-0.cov coverage-mysql-1-4.cov
6662
coverage report
6763
coverage xml
6864
coverage html

.github/workflows/publish.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ jobs:
3434

3535
runs-on: ubuntu-latest
3636

37-
services:
38-
singlestore:
39-
image: ghcr.io/singlestore-labs/singlestoredb-dev:latest
40-
ports:
41-
- 3307:3306
42-
- 8081:8080
43-
- 9080:9000
44-
env:
45-
SINGLESTORE_LICENSE: ${{ secrets.SINGLESTORE_LICENSE }}
46-
ROOT_PASSWORD: "root"
37+
# services:
38+
# singlestore:
39+
# image: ghcr.io/singlestore-labs/singlestoredb-dev:latest
40+
# ports:
41+
# - 3307:3306
42+
# - 8081:8080
43+
# - 9080:9000
44+
# env:
45+
# SINGLESTORE_LICENSE: ${{ secrets.SINGLESTORE_LICENSE }}
46+
# ROOT_PASSWORD: "root"
4747

4848
steps:
4949
- uses: actions/checkout@v3

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
## Editor temporary/working/backup files
2+
.hypothesis
3+
.serena
4+
.claude
5+
CLAUDE.md
6+
dev-docs
27
.#*
38
*\#*\#
49
[#]*#
@@ -57,6 +62,7 @@ dist
5762
# wheel files
5863
*.whl
5964
**/wheelhouse/*
65+
**/.hypothesis
6066
# coverage
6167
.coverage
6268
swat.egg-info/
@@ -73,6 +79,20 @@ ehthumbs.db
7379
Icon?
7480
Thumbs.db
7581

82+
**/CLAUDE.md
83+
.claude
84+
.serena
85+
.vscode
86+
.venv
87+
**/.hypothesis
88+
dev-docs
89+
**/.ipynb_checkpoints
90+
**/.benchmarks
91+
*.ipynb
92+
certs
93+
**/*.prof
94+
**/*.pprof
95+
7696
## Documentation generated files
7797
docs/src/_build/doctrees
7898
docs/src/generated

CONTRIBUTING.md

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,64 @@ pip install -e ".[dev]"
3131

3232
This installs the package in editable mode along with all testing dependencies (pytest, pytest-cov, coverage).
3333

34-
The tests must be run in multiple modes: standard protocol and Data API (HTTP).
35-
If you have Docker installed, you can simply run the following:
34+
#### Test Connection Methods
35+
36+
The test infrastructure supports three connection methods:
37+
38+
**1. Docker Auto-Start (Recommended for Development)**
39+
40+
If Docker is installed and running, the test fixtures will automatically start a SingleStoreDB container:
41+
```bash
42+
# Docker container will auto-start, run tests, then stop
43+
pytest -v sqlalchemy_singlestoredb/tests
44+
```
45+
46+
**2. Using an Existing Server**
47+
48+
Set `SINGLESTOREDB_URL` to use an existing SingleStoreDB server instead of Docker:
49+
```bash
50+
# Direct connection using MySQL protocol
51+
SINGLESTOREDB_URL=user:[email protected]:3306 pytest -v sqlalchemy_singlestoredb/tests
52+
53+
# Data API connection using HTTP protocol
54+
SINGLESTOREDB_INIT_DB_URL=user:[email protected]:3306 \
55+
SINGLESTOREDB_URL=http://user:[email protected]:8090 \
56+
pytest -v sqlalchemy_singlestoredb/tests
3657
```
58+
59+
#### Required Test Modes
60+
61+
The tests must be run in **two connection modes** to ensure compatibility:
62+
63+
**1. Direct Connection (MySQL Protocol)** - Default mode:
64+
```bash
65+
# With Docker auto-start
3766
pytest -v sqlalchemy_singlestoredb/tests
38-
USE_DATA_API=1 pytest -v sqlalchemy_singlestoredb/tests
67+
68+
# With existing server
69+
SINGLESTOREDB_URL=user:pw@host:port pytest -v sqlalchemy_singlestoredb/tests
3970
```
4071

41-
You can also specify a SingleStoreDB server if you need to run against a
42-
specific server type:
72+
**2. Data API (HTTP Protocol)** - Use `USE_DATA_API=1`:
73+
```bash
74+
# With Docker auto-start (will use HTTP Data API)
75+
USE_DATA_API=1 pytest -v sqlalchemy_singlestoredb/tests
76+
77+
# With existing Data API server
78+
SINGLESTOREDB_INIT_DB_URL=user:[email protected]:3306 \
79+
SINGLESTOREDB_URL=http://user:pw@host:port \
80+
pytest -v sqlalchemy_singlestoredb/tests
4381
```
44-
SINGLESTOREDB_URL=user:[email protected]:3306 pytest -v sqlalchemy_singlestoredb/tests
45-
SINGLESTOREDB_URL=http://user:[email protected]:8090 pytest -v sqlalchemy_singlestoredb/tests
82+
83+
#### Test Output and Logging
84+
85+
The test fixtures include detailed logging that is **enabled by default**, showing:
86+
- Which connection method is being used (Docker vs existing server)
87+
- API type (Data API/HTTP vs Direct/MySQL protocol)
88+
- Connection URLs
89+
- Database creation/cleanup operations
90+
91+
This logging is configured in `pyproject.toml` and appears automatically when running tests. To disable it, use:
92+
```bash
93+
pytest --log-cli-level=WARNING sqlalchemy_singlestoredb/tests
4694
```

PLANNING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SingleStoreDB SQLAlchemy dialect
2+
3+
This project is an SQLAlchemy dialect for the SingleStoreDB database. The goal
4+
is to support as many of the SingleStoreDB features in the SQLAlchemy
5+
framework. The SingleStoreDB dialect is based on the MySQL dialect that is
6+
part of SQLAlchemy. SingleStoreDB uses the same protocol as MySQL, but does
7+
add a number of new features not supported by MySQL. Those need to be added
8+
to the SingleStoreDB SQLAlchemy dialect.
9+
10+
## Resources
11+
12+
- SingleStoreDB docs - https://docs.singlestore.com/
13+
- SQLAlchemy project web page - https://www.sqlalchemy.org/
14+
- SQLAlchemy project github repo - https://github.com/sqlalchemy/sqlalchemy/
15+
- SingleStoreDB Python SDK repo - https://github.com/singlestore-labs/singlestoredb-python/
16+
- Python language - https://python.org/doc/
17+
18+
19+
## Requirements
20+
21+
- Still requires SQLAlchemy v1.4 compatilibity
22+
- Must work for Python 3.9 or greater

0 commit comments

Comments
 (0)