Skip to main content

Python SQLAlchemy Dialect for StarRocks

Project description

StarRocks Python Client

A StarRocks client for the Python programming language.

StarRocks is the next-generation data platform designed to make data-intensive real-time analytics fast and easy. It delivers query speeds 5 to 10 times faster than other popular solutions. StarRocks can perform real-time analytics well while updating historical records. It can also enhance real-time analytics with historical data from data lakes easily. With StarRocks, you can get rid of the de-normalized tables and get the best performance and flexibility.

Installation

pip install starrocks

SQLAlchemy Usage

To connect to StarRocks using SQLAlchemy, use a connection string (URL) following this pattern:

  • User: User Name
  • Password: DBPassword
  • Host: StarRocks FE Host
  • Catalog: Catalog Name
  • Database: Database Name
  • Port: StarRocks FE port

Here's what the connection string looks like:

starrocks://<User>:<Password>@<Host>:<Port>/<Catalog>.<Database>

Example

It is recommended to use python 3.x to connect to the StarRocks database, eg:

from sqlalchemy import create_engine
from sqlalchemy.schema import Table, MetaData, Column
from sqlalchemy.sql.expression import select, text

engine = create_engine('starrocks://root:xxx@localhost:9030/hive_catalog.hive_db')
connection = engine.connect()

rows = connection.execute(text("SELECT * FROM hive_table")).fetchall()

meta = MetaData()
tbl = Table(
    'table1',
    meta,
    Column("id", Integer),
    starrocks_engine='OLAP',
    starrocks_comment='table comment',
    starrocks_properties=(
        ("storage_medium", "SSD"),
        ("storage_cooldown_time", "2015-06-04 00:00:00"),
    ))

meta.createall()
with connection.begin() as con:
    tbl.insert().values(id=1)
rows = connection.execute(tbl.select()).fetchall()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

starrocks-1.0.6.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

starrocks-1.0.6-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file starrocks-1.0.6.tar.gz.

File metadata

  • Download URL: starrocks-1.0.6.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for starrocks-1.0.6.tar.gz
Algorithm Hash digest
SHA256 0cf01e9677d9226624f08c7c849ccdb7422bde4861be489cd522053417b0c14f
MD5 055fdca61b5950f1169fb5143cbc4f12
BLAKE2b-256 766214478e24a1d3824155b6ad658082006ad55ab9ba4528da980a97eeaf4f0e

See more details on using hashes here.

File details

Details for the file starrocks-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: starrocks-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for starrocks-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4ba250ad66650a90de296111050b274cb4e593853bee5098ffe1c360c32e8378
MD5 26ab2ac65a63e1270b41ba81e819c603
BLAKE2b-256 8ef96ed8fc574b5243ef7101cdf5f34ff90d987e0bd36a16f98dc39444f3a7d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page