Skip to content

Commit b5fd235

Browse files
committed
Driver/Python: Add records
1 parent b3b2465 commit b5fd235

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/connect/python.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,28 @@ cx.read_sql(
270270

271271
- [Connect to CrateDB using ConnectorX]   [![Python ConnectorX](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)
272272

273+
(records)=
274+
### Records
275+
276+
[Records] is a very simple, but powerful, library for making raw SQL
277+
queries to most relational databases. Powered by SQLAlchemy and Tablib,
278+
it covers many database types and allows you to export your results to
279+
CSV, XLS, JSON, HTML Tables, YAML, or pandas dataframes with a single
280+
line of code.
281+
282+
```shell
283+
pip install --upgrade records sqlalchemy-cratedb
284+
```
285+
```python
286+
import records
287+
288+
db = records.Database("crate://", echo=True)
289+
rows = db.query("SELECT region, mountain, height FROM sys.summits ORDER BY height DESC LIMIT 3")
290+
data = rows.all()
291+
292+
print(rows.export("json"))
293+
```
294+
273295
(turbodbc)=
274296
### turbodbc
275297

@@ -344,6 +366,7 @@ How to use CrateDB together with popular open-source dataframe libraries.
344366
[httpx]: https://www.python-httpx.org/
345367
[psycopg 3]: https://www.psycopg.org/psycopg3/docs/
346368
[psycopg documentation]: https://www.psycopg.org/docs/
369+
[Records]: https://github.com/kennethreitz/records
347370
[turbodbc]: https://turbodbc.readthedocs.io/
348371

349372
[Connect to CrateDB using ConnectorX]: https://github.com/crate/cratedb-examples/tree/main/by-language/python-connectorx

0 commit comments

Comments
 (0)