-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
32 lines (24 loc) · 1.18 KB
/
test.py
File metadata and controls
32 lines (24 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# example_python.py
import asyncio
from maazdb_python import MaazDBClient
async def main():
server_url = "ws://localhost:8080"
client = MaazDBClient(server_url)
# Replace with your actual credentials and database name
username = "a" # Default admin user, CHANGE PASSWORD in permission.db!
password = "'" # Default admin password, CHANGE PASSWORD in permission.db!
db_name = "mydatabase.db"
await client.connect(username, password, db_name)
if client.websocket: # Only proceed if connection was successful
# Example SELECT query
select_query = "SELECT * FROM mytable" # Replace with your table name
select_response = await client.select_query(select_query)
print("SELECT Response:", select_response)
# Example INSERT query
insert_query = "INSERT INTO mytable (name, value) VALUES (:name, :value)" # Replace with your table name
insert_data = {"name": "test_name", "value": "test_value"}
insert_response = await client.insert_query(insert_query, insert_data)
print("INSERT Response:", insert_response)
await client.close_connection()
if __name__ == "__main__":
asyncio.run(main())