Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
302c2ae
feat: add AGENTS.md for project overview and setup instructions
qevolg Mar 27, 2026
4c1f8f4
Refactor taos-ws-py integration and update SQLAlchemy dialect handling
qevolg Mar 27, 2026
32ac190
chore: remove AGENTS.md as part of project restructuring
qevolg Mar 27, 2026
6bf539b
refactor: clean up code formatting and remove unnecessary blank lines
qevolg Mar 27, 2026
ffc5476
feat: update dependencies to include SQLAlchemy in workflow tests
qevolg Mar 27, 2026
e4646e3
refactor: enhance native module loading and improve error handling in…
qevolg Mar 27, 2026
5ced096
fix: correct connection string formatting and enhance query parameter…
qevolg Mar 27, 2026
04edc29
Update dependency versions in pyproject.toml and clean up test script
qevolg Mar 27, 2026
a5b7419
fix: normalize handling of explicit empty passwords in connection args
qevolg Mar 28, 2026
d98643e
fix: correct SQL query formatting in get_indexes method
qevolg Mar 28, 2026
3fff78d
feat: enhance SQLAlchemy dialect with improved SQL rendering and sche…
qevolg Mar 28, 2026
6f252b0
fix: streamline classifiers in pyproject.toml by removing redundant e…
qevolg Mar 30, 2026
46eff51
fix: simplify native module loading logic in __init__.py
qevolg Mar 30, 2026
460ea72
refactor: simplify SQL execution and testing logic in sqlalchemy.py a…
qevolg Mar 30, 2026
22d8599
refactor: clean up comments and streamline code in sqlalchemy.py
qevolg Mar 30, 2026
52f39b4
fix: update SQL query construction in BaseDialect to use f-strings fo…
qevolg Mar 30, 2026
47ed6dd
refactor: remove unused tests and constants from test_sqlalchemy.py
qevolg Mar 30, 2026
5db302a
refactor: streamline test_sqlalchemy.py by removing unused code and e…
qevolg Mar 30, 2026
fd3b9de
refactor: simplify assertions in test_decode_binary_in_tmq for clarit…
qevolg Mar 30, 2026
4affc35
test: add test for legacy taosws submodule alias availability
qevolg Mar 30, 2026
6896b7d
fix: update test_decode_binary_in_tmq to handle multiple values corre…
qevolg Mar 30, 2026
1868e6b
refactor: remove unused import from sqlalchemy.py
qevolg Mar 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/taos-ws-py-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,5 @@ jobs:
WS_CLOUD_TOKEN: ${{ secrets.WS_CLOUD_TOKEN }}
TEST_TD_3360: "true"
run: |
pip3 install pytest toml
pip3 install pytest toml sqlalchemy
pytest ./taos-ws-py/tests/
2 changes: 1 addition & 1 deletion .github/workflows/taos-ws-py-enterprise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,5 @@ jobs:
WS_CLOUD_TOKEN: ${{ secrets.WS_CLOUD_TOKEN }}
TEST_TD_ENTERPRISE: "true"
run: |
pip3 install pytest toml
pip3 install pytest toml sqlalchemy
pytest ./taos-ws-py/tests/
2 changes: 1 addition & 1 deletion .github/workflows/taos-ws-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ jobs:
WS_CLOUD_TOKEN: ${{ secrets.WS_CLOUD_TOKEN }}
run: |
curl -L -u "$TDENGINE_TEST_USERNAME:$TDENGINE_TEST_PASSWORD" -d "show databases" localhost:6041/rest/sql
pip3 install pytest toml
pip3 install pytest toml sqlalchemy
pip3 install ./
pytest ./taos-ws-py/tests/
Expand Down
2 changes: 1 addition & 1 deletion examples/pandas-read-sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

protocol_and_port = {"taos": 6030, "taosrest": 6041, "taosws": 6041}

for (protocol, port) in protocol_and_port.items():
for protocol, port in protocol_and_port.items():
engine = create_engine(f"{protocol}://root:taosdata@localhost")
conn = engine.connect()
res = pandas.read_sql(text("show databases"), conn)
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ packages = [{ include = "taos" }, { include = "taosrest" }]
[tool.poetry.plugins."sqlalchemy.dialects"]
"taos" = "taos.sqlalchemy:TaosDialect"
"taosrest" = "taosrest.sqlalchemy:TaosRestDialect"
"taosws" = "taos.sqlalchemy:TaosWsDialect"

[tool.poetry.dependencies]
python = ">=3.7,<4.0"
Expand Down
2 changes: 1 addition & 1 deletion taos-ws-py/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish = false
license = "MIT"

[lib]
name = "taosws"
name = "_taosws"
crate-type = ["cdylib"]

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion taos-ws-py/examples/schemaless_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!
import taosws
from taosws.taosws import PySchemalessProtocol, PySchemalessPrecision
from taosws import PySchemalessProtocol, PySchemalessPrecision

import taos

Expand Down
27 changes: 27 additions & 0 deletions taos-ws-py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[build-system]
requires = ["maturin>=1.8,<2.0"]
build-backend = "maturin"

[project]
name = "taos-ws-py"
dynamic = ["version"]
description = "The official TDengine Python websocket connector"
readme = "README.md"
requires-python = ">=3.7"
license = { text = "MIT" }
classifiers = [
"Programming Language :: Python",
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]

[project.optional-dependencies]
sqlalchemy = ["sqlalchemy>=2.0.0"]

[project.entry-points."sqlalchemy.dialects"]
taosws = "taosws.sqlalchemy:TaosWsDialect"

[tool.maturin]
python-source = "."
module-name = "taosws._taosws"
36 changes: 18 additions & 18 deletions taos-ws-py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,37 @@ shadow_rs::shadow!(build);
// ```

create_exception!(
taosws,
_taosws,
Warning,
PyException,
"Calling some methods will produce warning."
);
create_exception!(taosws, Error, PyException, "The root error exception");
create_exception!(_taosws, Error, PyException, "The root error exception");
create_exception!(
taosws,
_taosws,
InterfaceError,
PyException,
"The low-level api caused exception"
);
create_exception!(taosws, DatabaseError, Error);
create_exception!(taosws, DataError, DatabaseError);
create_exception!(taosws, OperationalError, DatabaseError);
create_exception!(taosws, IntegrityError, DatabaseError);
create_exception!(taosws, InternalError, DatabaseError);
create_exception!(taosws, ProgrammingError, DatabaseError);
create_exception!(taosws, NotSupportedError, DatabaseError);

create_exception!(taosws, QueryError, DatabaseError);
create_exception!(taosws, FetchError, DatabaseError);

create_exception!(taosws, ConnectionError, Error, "Connection error");
create_exception!(_taosws, DatabaseError, Error);
create_exception!(_taosws, DataError, DatabaseError);
create_exception!(_taosws, OperationalError, DatabaseError);
create_exception!(_taosws, IntegrityError, DatabaseError);
create_exception!(_taosws, InternalError, DatabaseError);
create_exception!(_taosws, ProgrammingError, DatabaseError);
create_exception!(_taosws, NotSupportedError, DatabaseError);

create_exception!(_taosws, QueryError, DatabaseError);
create_exception!(_taosws, FetchError, DatabaseError);

create_exception!(_taosws, ConnectionError, Error, "Connection error");
create_exception!(
taosws,
_taosws,
AlreadyClosedError,
ConnectionError,
"Connection error"
);
create_exception!(taosws, ConsumerException, Error);
create_exception!(_taosws, ConsumerException, Error);

mod common;
mod consumer;
Expand Down Expand Up @@ -1020,7 +1020,7 @@ fn blob_to_column(values: Vec<Option<Vec<u8>>>) -> PyColumnView {
}

#[pymodule]
fn taosws(py: Python<'_>, m: &PyModule) -> PyResult<()> {
fn _taosws(py: Python<'_>, m: &PyModule) -> PyResult<()> {
if std::env::var("RUST_LOG").is_ok() {
let _ = pretty_env_logger::try_init();
}
Expand Down
34 changes: 34 additions & 0 deletions taos-ws-py/taosws/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import importlib
import importlib.util
import pkgutil


__path__ = pkgutil.extend_path(__path__, __name__)


def _load_native_module():
for module_name in ("_taosws", "taosws"):
full_name = f"{__name__}.{module_name}"
if importlib.util.find_spec(full_name) is None:
continue
return importlib.import_module(full_name)

raise ImportError(
"Failed to import native extension 'taosws._taosws' or 'taosws.taosws'. "
"Ensure taos-ws-py is built and installed correctly."
)


_native = _load_native_module()

if hasattr(_native, "__all__"):
for name in _native.__all__:
globals()[name] = getattr(_native, name)
else:
for name in dir(_native):
if not name.startswith("_"):
globals()[name] = getattr(_native, name)

__doc__ = _native.__doc__
if hasattr(_native, "__all__"):
__all__ = _native.__all__
Loading
Loading