From af2ea44cebd152d3aefe018b0d6e454fb00a12d6 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Thu, 13 Jun 2024 21:29:00 +0200 Subject: [PATCH] Python: Add new project `sqlalchemy-cratedb` --- docs/connect/index.md | 10 +++++----- docs/connect/python.rst | 24 +++++++++++++++++++++++- docs/requirements.txt | 2 +- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/docs/connect/index.md b/docs/connect/index.md index b66814f..9033eae 100644 --- a/docs/connect/index.md +++ b/docs/connect/index.md @@ -415,7 +415,7 @@ For connecting to CrateDB from Python. Has support for [CrateDB BLOBs]. ```{sd-item} [![](https://img.shields.io/github/v/tag/crate/crate-python?label=latest)](https://github.com/crate/crate-python) [![](https://img.shields.io/badge/docs-by%20example-darkgreen)][python-dbapi-by-example] -[![](https://img.shields.io/badge/example-snippet-darkcyan)](#python) +[![](https://img.shields.io/badge/example-snippet-darkcyan)](#crate-python) ``` ::: @@ -423,15 +423,15 @@ For connecting to CrateDB from Python. Has support for [CrateDB BLOBs]. ```{sd-item} Python ``` ```{sd-item} -[SQLAlchemy dialect](https://cratedb.com/docs/python/en/latest/sqlalchemy.html) +[SQLAlchemy dialect](https://cratedb.com/docs/sqlalchemy-cratedb/) ``` ```{sd-item} For connecting to CrateDB from Python, using SQLAlchemy. ``` ```{sd-item} -[![](https://img.shields.io/github/v/tag/crate/crate-python?label=latest)](https://github.com/crate/crate-python) +[![](https://img.shields.io/github/v/tag/crate/sqlalchemy-cratedb?label=latest)](https://github.com/crate/sqlalchemy-cratedb) [![](https://img.shields.io/badge/docs-by%20example-darkgreen)][python-sqlalchemy-by-example] -[![](https://img.shields.io/badge/example-snippet-darkcyan)](#python) +[![](https://img.shields.io/badge/example-snippet-darkcyan)](#sqlalchemy-cratedb) ``` ::: @@ -497,6 +497,6 @@ ruby [ODBC]: https://en.wikipedia.org/wiki/Open_Database_Connectivity [PostgreSQL wire protocol]: https://www.postgresql.org/docs/current/protocol.html [python-dbapi-by-example]: inv:crate-python:*:label#by-example -[python-sqlalchemy-by-example]: inv:crate-python:*:label#sqlalchemy-by-example +[python-sqlalchemy-by-example]: inv:sqlalchemy-cratedb:*:label#by-example [schema]: inv:crate-reference:*:label#ddl-create-table-schemas [superuser]: inv:crate-reference:*:label#administration_user_management diff --git a/docs/connect/python.rst b/docs/connect/python.rst index fbb35d3..1db03a2 100644 --- a/docs/connect/python.rst +++ b/docs/connect/python.rst @@ -16,7 +16,7 @@ crate-python The ``crate`` Python package offers a database client implementation compatible with the Python Database API 2.0 specification, and also includes the CrateDB SQLAlchemy dialect. See the full documentation :ref:`here `. -The package can be installed using ``pip install crate[sqlalchemy]``. +The package can be installed using ``pip install crate``. .. code-block:: python @@ -30,6 +30,27 @@ The package can be installed using ``pip install crate[sqlalchemy]``. result = cursor.fetchone() print(result) +.. _sqlalchemy-cratedb: + +sqlalchemy-cratedb +------------------ + +The `SQLAlchemy`_ dialect for CrateDB, based on the HTTP-based DBAPI client +library `crate-python`_. +See the full documentation :ref:`here `. +The package can be installed using ``pip install sqlalchemy-cratedb``. + +.. code-block:: python + + import sqlalchemy as sa + + engine = sa.create_engine("crate://localhost:4200", echo=True) + connection = engine.connect() + + result = connection.execute(sa.text("SELECT * FROM sys.summits;")) + for record in result.all(): + print(record) + .. _psycopg2: psycopg2 @@ -139,3 +160,4 @@ For more information, see the `asyncpg documentation`_. .. _asyncpg documentation: https://magicstack.github.io/asyncpg/current/ .. _psycopg documentation: https://www.psycopg.org/docs/ .. _Psycopg 3: https://www.psycopg.org/psycopg3/docs/ +.. _SQLAlchemy: https://www.sqlalchemy.org/ diff --git a/docs/requirements.txt b/docs/requirements.txt index ced14fe..1195bb2 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1 +1 @@ -crate-docs-theme +crate-docs-theme==0.32.4dev2