Skip to content

Commit 61fd51c

Browse files
committed
Simple README added
1 parent 5a8d28b commit 61fd51c

File tree

2 files changed

+174
-111
lines changed

2 files changed

+174
-111
lines changed

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# YDB Python DBAPI
2+
3+
## Introduction
4+
5+
Python DBAPI to `YDB`, which provides both sync and async drivers and complies with [PEP249](https://www.python.org/dev/peps/pep-0249/).
6+
7+
## Installation
8+
9+
**TBD after first release**
10+
11+
## Usage
12+
13+
To establish a new DBAPI connection you should provide `host`, `port` and `database`:
14+
15+
```python
16+
import ydb_dbapi
17+
18+
connection = ydb_dbapi.connect(
19+
host="localhost", port="2136", database="/local"
20+
) # sync connection
21+
22+
async_connection = await ydb_dbapi.async_connect(
23+
host="localhost", port="2136", database="/local"
24+
) # async connection
25+
```
26+
27+
Usage of connection:
28+
29+
```python
30+
with connection.cursor() as cursor:
31+
cursor.execute("SELECT id, val FROM table")
32+
33+
row = cursor.fetchone()
34+
rows = cursor.fetchmany(size=5)
35+
rows = cursor.fetchall()
36+
```
37+
38+
Usage of async connection:
39+
40+
```python
41+
async with async_connection.cursor() as cursor:
42+
await cursor.execute("SELECT id, val FROM table")
43+
44+
row = await cursor.fetchone()
45+
rows = await cursor.fetchmany(size=5)
46+
rows = await cursor.fetchall()
47+
```

0 commit comments

Comments
 (0)