You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
640 B
25 lines
640 B
from tinydb import TinyDB, Query |
|
|
|
from tinydb.operations import add |
|
|
|
# Initialize the database |
|
db = TinyDB('db.json') |
|
|
|
# Access the 'users' table |
|
users = db.table('users') |
|
|
|
# Insert a new user |
|
user_id = users.insert({'nome': 'Jim', 'cognome': 'Doe', 'livello': 2, |
|
'sede': 1, 'telefono': '1234567890', 'instagram': '@johndoe', |
|
'pagamenti': ['2023-01-01T00:00:00', '2022-02-01T00:00:00'], 'presenze': []}) |
|
|
|
print(user_id) |
|
|
|
# Define the user query |
|
User = Query() |
|
|
|
# Update the 'presenze' field for the newly inserted user |
|
users.update(add('presenze', [{'Country':'USA'}])) |
|
# Print all users |
|
res = users.all() |
|
print(res)
|
|
|