From f04ca12d9c17aeb69855e9ae1904d303d7fc6e75 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Mon, 8 Apr 2024 18:24:09 +0200 Subject: [PATCH] Client Drivers: Improve linking between enumeration list and examples --- docs/connect/index.md | 4 ++-- docs/connect/python.rst | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/connect/index.md b/docs/connect/index.md index 1fc37e8..b66814f 100644 --- a/docs/connect/index.md +++ b/docs/connect/index.md @@ -318,7 +318,7 @@ For connecting to CrateDB from Python, supporting Python's `asyncio`. ``` ```{sd-item} [![](https://img.shields.io/github/v/tag/MagicStack/asyncpg?label=latest)](https://github.com/MagicStack/asyncpg) -[![](https://img.shields.io/badge/example-snippet-darkcyan)](#python) +[![](https://img.shields.io/badge/example-snippet-darkcyan)](#psycopg2) ``` ::: @@ -333,7 +333,7 @@ For connecting to CrateDB from Python, supporting Python's `asyncio`. ``` ```{sd-item} [![](https://img.shields.io/github/v/tag/psycopg/psycopg?label=latest)](https://github.com/psycopg/psycopg) -[![](https://img.shields.io/badge/example-snippet-darkcyan)](#python) +[![](https://img.shields.io/badge/example-snippet-darkcyan)](#psycopg3) ``` ::: diff --git a/docs/connect/python.rst b/docs/connect/python.rst index 65b3603..fbb35d3 100644 --- a/docs/connect/python.rst +++ b/docs/connect/python.rst @@ -8,6 +8,8 @@ This guide demonstrates how to connect to a CrateDB Cloud cluster using differen kinds of Python drivers. Individual drivers offer specific features for specific needs of your application, so consider reading this enumeration carefully. +.. _crate-python: + crate-python ------------ @@ -24,10 +26,12 @@ The package can be installed using ``pip install crate[sqlalchemy]``. with conn: cursor = conn.cursor() - cursor.execute("SELECT name FROM sys.cluster") + cursor.execute("SELECT * FROM sys.summits") result = cursor.fetchone() print(result) +.. _psycopg2: + psycopg2 -------- @@ -44,10 +48,12 @@ For more information, see the `psycopg documentation`_. with conn: with conn.cursor() as cursor: - cursor.execute("SELECT name FROM sys.cluster") + cursor.execute("SELECT * FROM sys.summits") result = cursor.fetchone() print(result) +.. _psycopg3: + psycopg3 -------- @@ -95,13 +101,15 @@ For more information, see the `aiopg documentation`_. async with aiopg.create_pool(host=".cratedb.net", port=5432, user="admin", password="", sslmode="require") as pool: async with pool.acquire() as conn: async with conn.cursor() as cursor: - await cursor.execute("SELECT name FROM sys.cluster") + await cursor.execute("SELECT * FROM sys.summits") result = await cursor.fetchone() print(result) loop = asyncio.get_event_loop() loop.run_until_complete(run()) +.. _asyncpg: + asyncpg ------- @@ -118,7 +126,7 @@ For more information, see the `asyncpg documentation`_. async def run(): conn = await asyncpg.connect(host=".cratedb.net", port=5432, user="admin", password="", ssl=True) try: - result = await conn.fetch("SELECT name FROM sys.cluster") + result = await conn.fetch("SELECT * FROM sys.summits") finally: await conn.close() print(result)