-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_database.py
More file actions
25 lines (19 loc) · 831 Bytes
/
check_database.py
File metadata and controls
25 lines (19 loc) · 831 Bytes
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
import pickle
from databasestructure import *
if __name__ == '__main__':
# Load the database from binary format
loaded_db = CustomDatabase.load('./avl_database.pkl')
row_header, user_row = loaded_db.select('users', 0)
print("\nPrint user with id 0:\n", row_header, '\n', user_row)
# Insert new data
loaded_db.insert('users', [None, 'Antonio', 35])
loaded_db.commit('users')
print("\nInserted new user in users")
# Select by value
header, user = loaded_db.select_by_column_value("users", "age", '>', 25)
print("\nSelect user row:\n", header,'\n', user)
# Select all data
headers, table = loaded_db.select_all('users')
print("\nSelect all users table:\n", headers, '\n', table)
# AFTER COMMITS ARE MADE, WRITE TO THE DATABASE
loaded_db.save('./avl_database.pkl')