old
This commit is contained in:
53
database.py
53
database.py
@@ -1,53 +0,0 @@
|
|||||||
import sqlite3
|
|
||||||
|
|
||||||
def create_tables():
|
|
||||||
conn = sqlite3.connect('bot_data.db')
|
|
||||||
cursor = conn.cursor()
|
|
||||||
|
|
||||||
cursor.execute('''
|
|
||||||
CREATE TABLE IF NOT EXISTS orders (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
name TEXT,
|
|
||||||
phone TEXT,
|
|
||||||
address TEXT,
|
|
||||||
cleaning_time TEXT,
|
|
||||||
cleaning_type TEXT,
|
|
||||||
payment_method TEXT
|
|
||||||
)
|
|
||||||
''')
|
|
||||||
|
|
||||||
cursor.execute('''
|
|
||||||
CREATE TABLE IF NOT EXISTS users (
|
|
||||||
user_id INTEGER PRIMARY KEY,
|
|
||||||
name TEXT,
|
|
||||||
phone TEXT,
|
|
||||||
address TEXT
|
|
||||||
)
|
|
||||||
''')
|
|
||||||
|
|
||||||
conn.commit()
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def add_order(name, phone, address, cleaning_time, cleaning_type, payment_method):
|
|
||||||
conn = sqlite3.connect('bot_data.db')
|
|
||||||
cursor = conn.cursor()
|
|
||||||
|
|
||||||
cursor.execute('''
|
|
||||||
INSERT INTO orders (name, phone, address, cleaning_time, cleaning_type, payment_method)
|
|
||||||
VALUES (?, ?, ?, ?, ?, ?)
|
|
||||||
''', (name, phone, address, cleaning_time, cleaning_type, payment_method))
|
|
||||||
|
|
||||||
conn.commit()
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def get_order_history(user_id):
|
|
||||||
conn = sqlite3.connect('bot_data.db')
|
|
||||||
cursor = conn.cursor()
|
|
||||||
|
|
||||||
cursor.execute('''
|
|
||||||
SELECT * FROM orders WHERE user_id = ?
|
|
||||||
''', (user_id,))
|
|
||||||
|
|
||||||
orders = cursor.fetchall()
|
|
||||||
conn.close()
|
|
||||||
return orders
|
|
||||||
|
|||||||
0
bot-market/.idea/.gitignore → doners/bot-market/.idea/.gitignore
generated
vendored
0
bot-market/.idea/.gitignore → doners/bot-market/.idea/.gitignore
generated
vendored
53
doners/old_2/database.py
Normal file
53
doners/old_2/database.py
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import sqlite3
|
||||||
|
|
||||||
|
def create_tables():
|
||||||
|
conn = sqlite3.connect('bot_data.db')
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
cursor.execute('''
|
||||||
|
CREATE TABLE IF NOT EXISTS orders (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
name TEXT,
|
||||||
|
phone TEXT,
|
||||||
|
address TEXT,
|
||||||
|
cleaning_time TEXT,
|
||||||
|
cleaning_type TEXT,
|
||||||
|
payment_method TEXT
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
|
||||||
|
cursor.execute('''
|
||||||
|
CREATE TABLE IF NOT EXISTS users (
|
||||||
|
user_id INTEGER PRIMARY KEY,
|
||||||
|
name TEXT,
|
||||||
|
phone TEXT,
|
||||||
|
address TEXT
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
def add_order(name, phone, address, cleaning_time, cleaning_type, payment_method):
|
||||||
|
conn = sqlite3.connect('bot_data.db')
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
cursor.execute('''
|
||||||
|
INSERT INTO orders (name, phone, address, cleaning_time, cleaning_type, payment_method)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?)
|
||||||
|
''', (name, phone, address, cleaning_time, cleaning_type, payment_method))
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
def get_order_history(user_id):
|
||||||
|
conn = sqlite3.connect('bot_data.db')
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
cursor.execute('''
|
||||||
|
SELECT * FROM orders WHERE user_id = ?
|
||||||
|
''', (user_id,))
|
||||||
|
|
||||||
|
orders = cursor.fetchall()
|
||||||
|
conn.close()
|
||||||
|
return orders
|
||||||
0
handlers/__init__.py
Normal file
0
handlers/__init__.py
Normal file
0
handlers/admin.py
Normal file
0
handlers/admin.py
Normal file
0
handlers/polls.py
Normal file
0
handlers/polls.py
Normal file
0
handlers/start.py
Normal file
0
handlers/start.py
Normal file
0
keyboards/__init__.py
Normal file
0
keyboards/__init__.py
Normal file
0
keyboards/inline.py
Normal file
0
keyboards/inline.py
Normal file
0
middlewares/__init__.py
Normal file
0
middlewares/__init__.py
Normal file
0
middlewares/logging.py
Normal file
0
middlewares/logging.py
Normal file
0
models/__init__.py
Normal file
0
models/__init__.py
Normal file
0
models/poll.py
Normal file
0
models/poll.py
Normal file
0
utils/__init__.py
Normal file
0
utils/__init__.py
Normal file
0
utils/misc.py
Normal file
0
utils/misc.py
Normal file
Reference in New Issue
Block a user