Skip to content
2 changes: 1 addition & 1 deletion docs/connect/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ application
java
javascript
php
python
python/index
ruby
natural
All drivers <drivers>
Expand Down
220 changes: 0 additions & 220 deletions docs/connect/python.md

This file was deleted.

27 changes: 27 additions & 0 deletions docs/connect/python/aiopg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(aiopg)=

# aiopg

aiopg is a python library for accessing a PostgreSQL database from the asyncio
(PEP-3156/tulip) framework. It wraps asynchronous features of the Psycopg
database driver.
For more information, see the [aiopg documentation].

```python
import asyncio
import aiopg

async def run():
async with aiopg.create_pool(host="<name-of-your-cluster>.cratedb.net", port=5432, user="admin", password="<PASSWORD>", sslmode="require") as pool:
async with pool.acquire() as conn:
async with conn.cursor() as cursor:
await cursor.execute("SELECT * FROM sys.summits")
result = await cursor.fetchone()
print(result)

loop = asyncio.get_event_loop()
loop.run_until_complete(run())
```


[aiopg documentation]: https://aiopg.readthedocs.io/
27 changes: 27 additions & 0 deletions docs/connect/python/asyncpg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(asyncpg)=

# asyncpg

asyncpg is a database interface library designed specifically for PostgreSQL
and Python/asyncio. asyncpg is an efficient, clean implementation of the
PostgreSQL server binary protocol for use with Python's asyncio framework.
For more information, see the [asyncpg documentation].

```python
import asyncio
import asyncpg

async def run():
conn = await asyncpg.connect(host="<name-of-your-cluster>.cratedb.net", port=5432, user="admin", password="<PASSWORD>", ssl=True)
try:
result = await conn.fetch("SELECT * FROM sys.summits")
finally:
await conn.close()
print(result)

loop = asyncio.get_event_loop()
loop.run_until_complete(run())
```


[asyncpg documentation]: https://magicstack.github.io/asyncpg/current/
34 changes: 34 additions & 0 deletions docs/connect/python/conecta.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(conecta-intro)=

# Conecta

:::{div} .float-right .text-right
[![conecta-core CI](https://github.com/surister/conecta/actions/workflows/test_core.yml/badge.svg)](https://github.com/surister/conecta/actions/workflows/test_core.yml)
[![conecta-python CI](https://github.com/surister/conecta/actions/workflows/test_python.yml/badge.svg)](https://github.com/surister/conecta/actions/workflows/test_python.yml)
:::
:::{div} .clearfix
:::

{ref}`conecta` is a library designed to load data from SQL databases into
Arrow with maximum speed and memory efficiency by leveraging zero-copy and
true concurrency in Python.

```python
from pprint import pprint
from conecta import read_sql

table = read_sql(
"postgres://crate:crate@localhost:5432/doc",
queries=["SELECT country, region, mountain, height, latitude(coordinates), longitude(coordinates) FROM sys.summits ORDER BY height DESC LIMIT 3"],
)

# Display in Python format.
pprint(table.to_pylist())

# Optionally convert to pandas dataframe.
print(table.to_pandas())

# Optionally convert to Polars dataframe.
import polars as pl
print(pl.from_arrow(table))
```
29 changes: 29 additions & 0 deletions docs/connect/python/connectorx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
(connectorx)=

# ConnectorX

:::{div} .float-right .text-right
[![ConnectorX CI](https://github.com/crate/cratedb-examples/actions/workflows/lang-python-connectorx.yml/badge.svg)](https://github.com/crate/cratedb-examples/actions/workflows/lang-python-connectorx.yml)
:::
:::{div} .clearfix
:::

[ConnectorX] enables you to load data from databases into Python in the
fastest and most memory-efficient way.

```python
import connectorx as cx

cx.read_sql(
"postgresql://username:password@server:port/database",
"SELECT * FROM lineitem",
partition_on="l_orderkey",
partition_num=10,
)
```

- [Connect to CrateDB using ConnectorX]


[ConnectorX]: https://sfu-db.github.io/connector-x/
[Connect to CrateDB using ConnectorX]: https://github.com/crate/cratedb-examples/tree/main/by-language/python-connectorx
30 changes: 30 additions & 0 deletions docs/connect/python/crate-python.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
(crate-python)=
# crate-python

:::{div} .float-right .text-right
[![Python DB API CI](https://github.com/crate/cratedb-examples/actions/workflows/lang-python-dbapi.yml/badge.svg)](https://github.com/crate/cratedb-examples/actions/workflows/lang-python-dbapi.yml)
:::
:::{div} .clearfix
:::

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 <crate-python:index>`.
The package can be installed using `pip install crate`.

```python
from crate import client

conn = client.connect("https://<name-of-your-cluster>.cratedb.net:4200", username="admin", password="<PASSWORD>", verify_ssl_cert=True)

with conn:
cursor = conn.cursor()
cursor.execute("SELECT * FROM sys.summits")
result = cursor.fetchone()
print(result)
```

- [Connect to CrateDB using the Python DB API]


[Connect to CrateDB using the Python DB API]: https://github.com/crate/cratedb-examples/tree/main/by-language/python-dbapi
Comment on lines +1 to +30
Copy link
Member Author

@amotl amotl Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide a runnable example for each item, e.g. by adding inline dependencies (PEP 723) implemented by uv, or by just adding a simple pip install ... incantation to the docs, followed up by an incantation how to invoke the program.

This has been conducted for all the other clients, so the Python area should not be left behind.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also what's inside this patch before closing it.

Loading