python_bot_v2/sql.py

28 lines
459 B
Python
Raw Normal View History

import sqlite3 as sq
2022-11-07 19:58:59 +10:00
2022-11-07 00:52:46 +10:00
async def db_start(): #подключение к бд
global db, cur
2022-11-07 20:09:09 +10:00
db = sq.connect('users.db')
cur = db.cursor()
2022-11-07 20:02:30 +10:00
cur.execute(''''CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, users_id INTEGER, user_name TEXT)''')
db.commit()
2022-11-07 19:58:59 +10:00
async def add_user():
2022-11-07 20:11:37 +10:00
cur.execute('''INSERT INTO users (users_id, user_name) VALUES (?, ?)''')
db.commit()
2022-11-07 19:58:59 +10:00
async def close():
2022-11-07 20:11:37 +10:00
db.commit()
db.close()
2022-11-07 00:52:46 +10:00