import s_taper, pickle import s_taper.aio import aiosqlite from s_taper.consts import * from random import randrange import random title = { 'user_id': INT+KEY, 'user_name': TEXT, 'user_age': FLT, 'first': BLN } users = s_taper.Taper('users', 'data.db').create_table(title) title_2 = { 'user_id': INT+KEY, 'user_name': TEXT, 'order_id': INT, 'how_many': INT, 'art': INT, 'money': INT } orders = s_taper.Taper('orders', 'data.db').create_table(title_2) # orders.write([2048, 'Opalami', 1, 8, 2575893, 16894]) # t_f = [True, False] # for i in range(300): # user_id = i # user_name = f'user_{i}' # user_age = float(randrange(18, 120)) # first = random.choice(t_f) # users.write([user_id, user_name, user_age, first]) # orders.create_table(title_2, 'new_data') # for i in range(3000): # user_id = i # user_name = f'user_name_{i}' # order_id = i # how_many = random.randrange(1, 1000) # art = random.randrange(1, 100000) # money = how_many*randrange(10, 10000) # orders.write([user_id, user_name, order_id, how_many, art, money]) user = users.read('user_id', 2048) # new_user = '\n'.join(user) # print(users.read('user_age', 22)) # data = users.read_all() # old_users =[] # for liste in data: # if liste[2] >=100: # old_users.append(liste) # id = len(data) # # print(f'Всего пожилых users: {len(old_users)}\nПроцент от всего числа пользователей: {(len(old_users*100))//id} %') # new_data = users.read_obj('user_age', 22) # # new_users = [] # for key in range(0, 300): # # new_user = users.read_obj('user_id', key) # if new_user.first: # new_users.append(new_user.__dict__) # print(len(new_users)) # print(new_data.__dict__) # print(new_data.user_age) # # orders.delete_row(all_rows=True) # orders.drop_table() # # orders.drop_table('new_data') inic = {'iniciali':['Max', 'Bond', 'Dan']} # inic = pickle.dumps(inic) users.write([123124, inic, 17.0, True]) inf = users.read('user_id', key=123124) infor = inf[1] print(infor)