From 1069a20093aa2c9904b9cbc1206e857e3f2b1097 Mon Sep 17 00:00:00 2001 From: Pavel_Duron Date: Mon, 7 Nov 2022 19:58:59 +1000 Subject: [PATCH] =?UTF-8?q?=D1=82=D1=81=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot.py | 5 ++++- sql.py | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bot.py b/bot.py index dff99a9..7c34f0d 100644 --- a/bot.py +++ b/bot.py @@ -5,6 +5,7 @@ from random import randint from aiogram import Bot, Dispatcher, executor, types from aiogram.types import ReplyKeyboardRemove, ReplyKeyboardMarkup, KeyboardButton +import sql @@ -48,8 +49,10 @@ async def dick(message: types.Message): async def ident(message: types.Message): id1 = message.from_user.id fullname1 = message.from_user.full_name - #await sql.add_user() + sql.db_start await bot.send_message(message.chat.id, f'{id1} + {fullname1}') + sql.add_user + sql.close #await sql.db.close() diff --git a/sql.py b/sql.py index 35d59dd..f3dcbe0 100644 --- a/sql.py +++ b/sql.py @@ -1,5 +1,5 @@ import sqlite3 as sq -import aiogram + async def db_start(): #подключение к бд global db, cur @@ -10,12 +10,12 @@ async def db_start(): #подключение к бд cur.execute(''''CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, users_id INTEGER, user_name TEXT, dick_size INTEGER)''') db.commit() -async def add_user(id): - cur.execute('''INSERT INTO users (users_id, user_name) VALUES (?)''',[id, fullname]) +async def add_user(): + cur.execute('''INSERT INTO users (users_id, user_name) VALUES (?)''',[id1, fullname1]) db.commit() - -db.commit() +async def close(): + db.close()