import sqlite3
with sqlite3.connect('allusers.db') as db:
cursor = db.cursor()
cursor.execute('''
create table if not exists users (
id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
chat_id INTEGER UNIQUE,
username_tg text UNIQUE,
surname text,
name text,
patronymic text,
class_digit integer,
class_letter text,
year_of_birth integer,
watch_right integer,
rent_right integer,
release_right integer,
order_right integer,
add_right integer,
remove_right integer,
useradd_right integer,
userdelete_right integer,
adminadd_right integer,
adddelete_right integer,
glavadmin integer)''')
cursor.execute('''
create table if not exists tag_table (
id INTEGER PRIMARY KEY AUTOINCREMENT,
tag text)''')
cursor.execute('''
create table if not exists items (
id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
parent_id FOREIGH KEY INTEGER,
FOREIGH KEY(parent_id) REFERENCES items (id),
description text,
name text,
model text,
tags integer,
FOREIGH KEY(tags) REFERENCES tag_table (tag))''')
cursor.execute('''
create table if not exists real_items (
id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
item_id INTEGER,
FOREIGH KEY(item_id) REFERENCES items (id),
count INTEGER,
place TEXT,
state TEXT,
respman_id INTEGER,
FOREIGH KEY(respman_id) REFERENCES users (id),
importance INTEGER)''')