Skip to content

Commit 86e11b2

Browse files
authored
doc: fix the example
1 parent af2ea3a commit 86e11b2

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,19 @@ Successfully installed tikv-client-0.1.0
4444
Python TiKV client is synchronous by defult:
4545

4646
```python
47-
from tikv_client import TransactionClient
47+
from tikv_client import RawClient
4848

49-
client = TransactionClient.connect("127.0.0.1:2379")
49+
client = RawClient.connect(["127.0.0.1:2379"])
5050

51-
txn = client.begin(pessimistic=True)
52-
txn.put(b"k1", b"v1")
53-
txn.put(b"k2", b"v2")
54-
txn.put(b"k3", b"v3")
55-
txn.put(b"k4", b"v4")
56-
txn.put(b"k5", b"v5")
57-
txn.commit()
51+
client.put(b"k1", b"v1")
52+
client.put(b"k2", b"v2")
53+
client.put(b"k3", b"v3")
54+
client.batch_put({b"k4": b"v4", b"k5": b"v5"})
5855

59-
snapshot = client.snapshot(client.current_timestamp())
60-
print(snapshot.get(b"k3"))
61-
print(snapshot.batch_get([b"k1", b"k4"]))
56+
print(client.get(b"k3"))
57+
print(client.batch_get([b"k1", b"k4"]))
6258

63-
for k, v in snapshot.scan(b"k1", end=None, limit=10, include_start=False):
59+
for k, v in client.scan(b"k1", end=None, limit=10, include_start=False):
6460
print(k, v)
6561
```
6662

@@ -71,7 +67,7 @@ import asyncio
7167
from tikv_client.asynchronous import TransactionClient
7268

7369
async def main():
74-
client = await TransactionClient.connect("127.0.0.1:2379")
70+
client = await TransactionClient.connect(["127.0.0.1:2379"])
7571

7672
txn = await client.begin(pessimistic=True)
7773
await txn.put(b"k1", b"v1")
@@ -81,7 +77,7 @@ async def main():
8177
await txn.put(b"k5", b"v5")
8278
await txn.commit()
8379

84-
snapshot = client.snapshot(await client.current_timestamp())
80+
snapshot = client.snapshot(await client.current_timestamp(), pessimistic=True)
8581
print(await snapshot.get(b"k3"))
8682
print(await snapshot.batch_get([b"k1", b"k4"]))
8783

0 commit comments

Comments
 (0)