Код: Выделить всё
def make_a_transaction(current_cursor, account: str, type_of_transaction: str, category: str,
amount: float, currency: str = 'USD',
date_of_transaction: str = str(datetime.now())[:19], description_of_transaction: str = ''):
current_cursor.execute('INSERT INTO Transactions (account, type_of_transaction, category, amount, currency, '
'date_of_transaction, description_of_transaction) VALUES (?, ?, ?, ?, ?, ?, ?)',
(account, type_of_transaction, category, amount, currency,
date_of_transaction, description_of_transaction))
Код: Выделить всё
cursor.execute('SELECT DISTINCT category FROM Transactions')
if category not in cursor.fetchall():
print('Choose category from the list of existing categories')
Подробнее здесь: https://stackoverflow.com/questions/787 ... -sql-table