Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,19 @@ Successfully installed tikv-client-0.1.0
Python TiKV client is synchronous by defult:

```python
from tikv_client import TransactionClient
from tikv_client import RawClient

client = TransactionClient.connect("127.0.0.1:2379")
client = RawClient.connect(["127.0.0.1:2379"])

txn = client.begin(pessimistic=True)
txn.put(b"k1", b"v1")
txn.put(b"k2", b"v2")
txn.put(b"k3", b"v3")
txn.put(b"k4", b"v4")
txn.put(b"k5", b"v5")
txn.commit()
client.put(b"k1", b"v1")
client.put(b"k2", b"v2")
client.put(b"k3", b"v3")
client.batch_put({b"k4": b"v4", b"k5": b"v5"})

snapshot = client.snapshot(client.current_timestamp())
print(snapshot.get(b"k3"))
print(snapshot.batch_get([b"k1", b"k4"]))
print(client.get(b"k3"))
print(client.batch_get([b"k1", b"k4"]))

for k, v in snapshot.scan(b"k1", end=None, limit=10, include_start=False):
for k, v in client.scan(b"k1", end=None, limit=10, include_start=False):
print(k, v)
```

Expand All @@ -71,7 +67,7 @@ import asyncio
from tikv_client.asynchronous import TransactionClient

async def main():
client = await TransactionClient.connect("127.0.0.1:2379")
client = await TransactionClient.connect(["127.0.0.1:2379"])

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

snapshot = client.snapshot(await client.current_timestamp())
snapshot = client.snapshot(await client.current_timestamp(), pessimistic=True)
print(await snapshot.get(b"k3"))
print(await snapshot.batch_get([b"k1", b"k4"]))

Expand Down