27 lines
782 B
Python
Executable File
27 lines
782 B
Python
Executable File
from create_bot import bot
|
|
import sqlite3 as sq
|
|
|
|
base = None
|
|
cur = None
|
|
|
|
|
|
def sql_start():
|
|
global base, cur
|
|
base = sq.connect("pizza_cool.db")
|
|
cur = base.cursor()
|
|
if base:
|
|
print("Data base connected OK!")
|
|
base.execute("CREATE TABLE IF NOT EXISTS menu(img TEXT, name TEXT PRIMARY KEY, description TEXT, price TEXT)")
|
|
base.commit()
|
|
|
|
|
|
async def sql_add_command(state):
|
|
async with state.proxy() as data:
|
|
cur.execute("INSERT INTO menu VALUES (?, ?, ?, ?)", tuple(data.values()))
|
|
base.commit()
|
|
|
|
|
|
async def sql_reade(message):
|
|
for ret in cur.execute("SELECT * FROM menu").fetchall():
|
|
await bot.send_photo(message.from_user.id, ret[0], f"\n{ret[1]}\nОписание: {ret[2]}\nЦена: {ret[-1]}")
|