Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@ In active development.. Check back later!

### Usage

```
# Open the database
db = TidesDB.open('/path/to/tidesdb')
```py
# open a database
db = TidesDB.open('/your_db_path')

# Create a column family
# create a column family
db.create_column_family("cf_name", 100, 3, 0.5, True, 1, True)

# Start a transaction
# start a transaction
txn = Transaction.begin(db, "cf_name")

# Put a key-value pair in the transaction
txn.put(b"my_key", b"my_value", 3600)

# Commit the transaction
# commit the transaction
txn.commit()

# Get the value back from the database
# get the value back from the database
value = db.get("cf_name", b"my_key")
print(value)

# Start a cursor to iterate over key-value pairs
# start a cursor to iterate over key-value pairs
cursor = Cursor.init(db, "cf_name")
cursor.next() # or cursor.prev()
key, value = cursor.get()
print(key, value)

# Clean up resources
# clean up resources
cursor.free()
db.close()
```
3 changes: 3 additions & 0 deletions tidesdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# Load the tidesdb library
lib = ctypes.CDLL('PATH_TO_TIDESDB_LIB')

# TidesDB class
class TidesDB:
def __init__(self, tdb):
self.tdb = tdb
Expand Down Expand Up @@ -86,6 +87,7 @@ def list_column_families(self):
raise Exception("Failed to list column families")
return ctypes.string_at(cf_list).decode('utf-8')

# Cursor class to iterate over a column family key value pairs
class Cursor:
def __init__(self, cursor):
self.cursor = cursor
Expand Down Expand Up @@ -126,6 +128,7 @@ def free(self):
if result != 0:
raise Exception("Failed to free cursor")

# Transaction class for TidesDB column family transactions
class Transaction:
def __init__(self, txn):
self.txn = txn
Expand Down