Skip to content

Commit 014e41a

Browse files
authored
Update install.md
1 parent 238258b commit 014e41a

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

docs/install.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,31 @@ print(res, end="")
251251
<!-- tabs:end -->
252252
<!-- tabs:start -->
253253

254+
#### **Python DB API**
255+
256+
The chDB Python package adheres to the Python DB API ([PEP 249](https://peps.python.org/pep-0249/)), so you can use it just like you'd use stdlib's `sqlite3` module:
257+
258+
```python
259+
from contextlib import closing
260+
from chdb import dbapi
261+
262+
print(f"chdb version: {dbapi.get_client_info()}")
263+
264+
with closing(dbapi.connect()) as conn:
265+
with closing(conn.cursor()) as cur:
266+
cur.execute("SELECT version()")
267+
print("description:", cur.description)
268+
print("data:", cur.fetchone())
269+
```
270+
271+
<codapi-snippet sandbox="chdb-python" editor="basic">
272+
</codapi-snippet>
273+
274+
For more examples, see [examples](https://github.com/chdb-io/chdb/tree/main/examples) and [tests](https://github.com/chdb-io/chdb/tree/main/tests).
275+
276+
<!-- tabs:end -->
277+
<!-- tabs:start -->
278+
254279
#### **User-defined functions**
255280

256281
We can define a function in Python and use it in chDB SQL queries.
@@ -320,31 +345,6 @@ chDB Python UDF requirements:
320345

321346
<!-- tabs:end -->
322347

323-
<!-- tabs:start -->
324-
325-
#### **Python DB API**
326-
327-
The chDB Python package adheres to the Python DB API ([PEP 249](https://peps.python.org/pep-0249/)), so you can use it just like you'd use stdlib's `sqlite3` module:
328-
329-
```python
330-
from contextlib import closing
331-
from chdb import dbapi
332-
333-
print(f"chdb version: {dbapi.get_client_info()}")
334-
335-
with closing(dbapi.connect()) as conn:
336-
with closing(conn.cursor()) as cur:
337-
cur.execute("SELECT version()")
338-
print("description:", cur.description)
339-
print("data:", cur.fetchone())
340-
```
341-
342-
<codapi-snippet sandbox="chdb-python" editor="basic">
343-
</codapi-snippet>
344-
345-
For more examples, see [examples](https://github.com/chdb-io/chdb/tree/main/examples) and [tests](https://github.com/chdb-io/chdb/tree/main/tests).
346-
347-
<!-- tabs:end -->
348348

349349
<br>
350350

0 commit comments

Comments
 (0)