новая база на алхимии
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pavel_Duron 2022-11-08 20:43:34 +10:00
parent 7cba5b3eb5
commit ecbe804bf3
7 changed files with 42 additions and 32 deletions

Binary file not shown.

Binary file not shown.

10
bot.py
View File

@ -5,7 +5,7 @@ from random import randint
from aiogram import Bot, Dispatcher, executor, types
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):
id1 = message.from_user.id
fullname1 = message.from_user.full_name
await sql.db_start
await bot.send_message(message.chat.id, f'{id1} + {fullname1}')
await sql.add_user
await sql.close
#await sql.db.close()

BIN
dick3.db Normal file

Binary file not shown.

0
dick31.db Normal file
View File

37
sqdb.py Normal file
View 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
View File

@ -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()