diff --git a/CHANGES.md b/CHANGES.md index 2e2da41..963644f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ ## Unreleased +- Added utility support wrapping CrateDB's special table options ## 2024/06/25 0.38.0 - Added/reactivated documentation as `sqlalchemy-cratedb` diff --git a/src/sqlalchemy_cratedb/support/__init__.py b/src/sqlalchemy_cratedb/support/__init__.py index d140d60..8f95b65 100644 --- a/src/sqlalchemy_cratedb/support/__init__.py +++ b/src/sqlalchemy_cratedb/support/__init__.py @@ -1,3 +1,4 @@ +from sqlalchemy_cratedb.support.model import TableOptions from sqlalchemy_cratedb.support.pandas import insert_bulk, table_kwargs from sqlalchemy_cratedb.support.polyfill import check_uniqueness_factory, refresh_after_dml, \ patch_autoincrement_timestamp @@ -11,4 +12,5 @@ refresh_dirty, refresh_table, table_kwargs, + TableOptions, ] diff --git a/src/sqlalchemy_cratedb/support/model.py b/src/sqlalchemy_cratedb/support/model.py new file mode 100644 index 0000000..a93b109 --- /dev/null +++ b/src/sqlalchemy_cratedb/support/model.py @@ -0,0 +1,336 @@ +import dataclasses +import typing as t +from collections import OrderedDict +from urllib.parse import urlparse, parse_qs, parse_qsl + +from sqlalchemy.util import asbool + + +@dataclasses.dataclass +class TableOptionSpec: + name: str + type: t.Optional[str] = None + default: t.Optional[t.Any] = None + choices: t.Optional[list] = None + translate: t.Optional[t.Dict[str, str]] = None + unit: t.Optional[str] = None + description: t.Optional[str] = None + docs: t.Optional[str] = None + + +class TableOptions(dict): + """ + Manage a dictionary of SQLAlchemy dialect options in `_