зачал бд, удалил лишнее
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pavel_Duron 2022-11-07 17:04:34 +10:00
parent e7d48632f4
commit 99533b80e6
2 changed files with 16 additions and 5 deletions

10
bot.py
View File

@ -5,9 +5,9 @@ from random import randint
from aiogram import Bot, Dispatcher, executor, types from aiogram import Bot, Dispatcher, executor, types
from aiogram.types import ReplyKeyboardRemove, ReplyKeyboardMarkup, KeyboardButton from aiogram.types import ReplyKeyboardRemove, ReplyKeyboardMarkup, KeyboardButton
#import sql import sql
#sql.db_start() sql.db_start()
API_TOKEN = '5724991559:AAEuLvpLsgP6LHRGMSyFtQLlR5qPQUO4b_w' API_TOKEN = '5724991559:AAEuLvpLsgP6LHRGMSyFtQLlR5qPQUO4b_w'
@ -45,6 +45,12 @@ async def dick(message: types.Message):
numb = (f"Рандомное число : {randint(-7,10)}") numb = (f"Рандомное число : {randint(-7,10)}")
await bot.send_message(message.chat.id, (numb)) await bot.send_message(message.chat.id, (numb))
@dp.message_handler(commands=["id"])
async def id(message: types.Message):
await sql.db_start()
await bot.send_message(message.chat.id, f'ваш id {message.from_user.id}')
await sql.db.close()
#####______________________ПИПИСА БОТ БУДЕТ ЗДЕСЬ__________________________________ #####______________________ПИПИСА БОТ БУДЕТ ЗДЕСЬ__________________________________

11
sql.py
View File

@ -6,14 +6,19 @@ async def db_start(): #подключение к бд
db = sq.connect('dickpick.db') db = sq.connect('dickpick.db')
cur = db.cursor() cur = db.cursor()
cur.execute('CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, users_id INTEGER, user_name TEXT, dick_size INTEGER)') cur.execute(''''CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, users_id INTEGER, user_name TEXT, dick_size INTEGER)''')
db.commit() db.commit()
async def add_user(): async def add_user(id):
cur.execute('INSERT INTO users (users_id, user_name) VALUES (?, ?,)'.format(message.from_user.id, message.from_user.fullname)) cur.execute('''INSERT INTO users (users_id) VALUES (?)''',(id))
id = message.from_user.id
db.commit() db.commit()
db.commit()