Apache Doris Dialect for SQLAlchemy
This is an unofficial implementation forked from pydoris
Features
- support SQLAlchemy 2.
- support pymysql and mysqlclient as driver.
- support SQLAlchemy table creation
Installation
Use
pip install sqlalchemy-doris[pymysql]
for pymysql.
Or
pip install sqlalchemy-doris[mysqldb]
for mysqlclient.
Note sqlalchemy-doris uses pymysql as default connector for compatibility. If both pymysql and mysqlclient are installed, mysqlclient is preferred.
Usage
from sqlalchemy import create_engine
engine = create_engine(f"doris+pymysql://{user}:{password}@{host}:{port}/{database}?charset=utf8mb4")
# or
engine = create_engine(f"doris+mysqldb://{user}:{password}@{host}:{port}/{database}?charset=utf8mb4")
Create Table
import sqlalchemy as sa
from sqlalchemy import create_engine
from sqlalchemy_doris import datatype
from sqlalchemy_doris import HASH, RANGE
engine = create_engine(f"doris://{user}:{password}@{host}:{port}/{database}?charset=utf8mb4")
metadata_obj = sa.MetaData()
table_obj = sa.Table(
'test_table',
metadata_obj,
sa.Column("id", datatype.Integer),
doris_unique_key=('id', ),
doris_partition_by=RANGE('id'),
doris_distributed_by=HASH('id'),
doris_properties={"replication_allocation": "tag.location.default: 1"}
)
metadata_obj.create_all(engine)
SQL is
CREATE TABLE test_table (
id INTEGER
)
UNIQUE KEY (`id`)
PARTITION BY RANGE(`id`) ()
DISTRIBUTED BY HASH(`id`) BUCKETS auto
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
)
Metadata
Release files for sqlalchemy-doris 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sqlalchemy_doris-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for sqlalchemy_doris-0.2.2-py3-none-any.whl |
Release files / sqlalchemy_doris-0.2.2-py3-none-any.whl
| Download URL | sqlalchemy_doris-0.2.2-py3-none-any.whl |
|---|---|
| Size | 13.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24c209d8f0090fb2784a4632e859331d216c349f8d242745721a370239ddd133
|
|
BLAKE2b-256 checksum How to use checksums |
92b1a0f02168fd48221f4e569b93d65c00257a4d90471c932524fedc0f758c1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.0
|
Security for sqlalchemy-doris 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.