Вторая часть: Небольшие дополнения и структура
This commit is contained in:
5
SQLite3/__init__.py
Normal file
5
SQLite3/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# SQLite3/__init__.py
|
||||
# Инициализация пакета SQLite3, для базы данных проекта
|
||||
|
||||
# Экспортирование модулей во внешние слои проекта
|
||||
from .bd import *
|
||||
23
SQLite3/bd.py
Normal file
23
SQLite3/bd.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# SQLite3/bd.py
|
||||
# Файл для работы с базой данных пользователей бота
|
||||
|
||||
import sqlite3
|
||||
|
||||
# Функция создания базы данных
|
||||
def create_user_db(bd_name : str = 'bd_user.db'):
|
||||
db = sqlite3.connect(bd_name)
|
||||
cursor = db.cursor()
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
user_id INTEGER PRIMARY KEY,
|
||||
tg_id INTEGER NOT NULL,
|
||||
username TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
status TEXT,
|
||||
last_message TEXT,
|
||||
last_message_time TIMESTAMP,
|
||||
UNIQUE(tg_id)
|
||||
);''')
|
||||
db.commit()
|
||||
db.close()
|
||||
BIN
SQLite3/bd_user.db
Normal file
BIN
SQLite3/bd_user.db
Normal file
Binary file not shown.
Reference in New Issue
Block a user