This commit is contained in:
parent
7cba5b3eb5
commit
ecbe804bf3
BIN
__pycache__/bot.cpython-310.pyc
Normal file
BIN
__pycache__/bot.cpython-310.pyc
Normal file
Binary file not shown.
Binary file not shown.
10
bot.py
10
bot.py
@ -5,7 +5,7 @@ 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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -49,11 +49,11 @@ async def dick(message: types.Message):
|
|||||||
async def ident(message: types.Message):
|
async def ident(message: types.Message):
|
||||||
id1 = message.from_user.id
|
id1 = message.from_user.id
|
||||||
fullname1 = message.from_user.full_name
|
fullname1 = message.from_user.full_name
|
||||||
await sql.db_start
|
|
||||||
await bot.send_message(message.chat.id, f'{id1} + {fullname1}')
|
await bot.send_message(message.chat.id, f'{id1} + {fullname1}')
|
||||||
await sql.add_user
|
|
||||||
await sql.close
|
|
||||||
#await sql.db.close()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
37
sqdb.py
Normal file
37
sqdb.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
from sqlalchemy import create_engine, MetaData, Table, Integer, String, \
|
||||||
|
Column, DateTime, ForeignKey, Numeric
|
||||||
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
|
engine = create_engine('sqlite:///dick3.db')
|
||||||
|
Session = sessionmaker(bind=engine)
|
||||||
|
session = Session()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Base = declarative_base()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class user(Base):
|
||||||
|
__tablename__ = 'users'
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True)
|
||||||
|
user_id = Column(Integer)
|
||||||
|
user_fullname = Column(String)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
c2 = user(user_id = 1234, user_fullname = 'dadad')
|
||||||
|
|
||||||
|
session.add(c2)
|
||||||
|
session.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
27
sql.py
27
sql.py
@ -1,27 +0,0 @@
|
|||||||
import sqlite3 as sq
|
|
||||||
|
|
||||||
|
|
||||||
async def db_start(): #подключение к бд
|
|
||||||
global db, cur
|
|
||||||
|
|
||||||
db = sq.connect('users.db')
|
|
||||||
cur = db.cursor()
|
|
||||||
|
|
||||||
cur.execute(''''CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, users_id INTEGER, user_name TEXT)''')
|
|
||||||
db.commit()
|
|
||||||
|
|
||||||
async def add_user():
|
|
||||||
cur.execute('''INSERT INTO users (users_id, user_name) VALUES (?, ?)''')
|
|
||||||
db.commit()
|
|
||||||
|
|
||||||
async def close():
|
|
||||||
db.commit()
|
|
||||||
db.close()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user