diff --git a/app/bot.py b/app/bot.py index f484bc8..bb737c9 100644 --- a/app/bot.py +++ b/app/bot.py @@ -554,9 +554,9 @@ def get_csv(message) -> None: connection = connect_db() bot_db = DatabaseQueries(connection) group_id: int = bot_db.get_group_id_by_telegram_id(telegram_id) - file_path: str = f"csv_tables/table_{group_id}.csv" + file_path: str = path.join(path.dirname(__file__), f"csv_tables/table_{group_id}.csv") table_headers: tuple = ("ID", "USERNAME", "TRANSFER", "TOTAL", "DATE", "CATEGORY", "DESCRIPTION") - table_data: tuple = bot_db.select_data_for_household_table(group_id, 0) + table_data: tuple[tuple, ...] = bot_db.select_data_for_household_table(group_id, 0) close_db(connection) if table_data: try: @@ -699,7 +699,7 @@ def process_delete_account(message, username: str): if user_choice == f"👍 {get_phrase_by_language(user_language, "YES")}": connection = connect_db() bot_db = DatabaseQueries(connection) - bot_db.delete_username_from_users(username) + bot_db.delete_username_from_users_by_telegram_id(telegram_id) close_db(connection) bot.send_message(message.chat.id, f"{get_phrase_by_language(user_language, "parting")}") bot.send_message(message.chat.id, f"{get_phrase_by_language(user_language, "account_is_deleted")}", diff --git a/app/build_project.py b/app/build_project.py index 4c8c903..5926195 100644 --- a/app/build_project.py +++ b/app/build_project.py @@ -1,3 +1,4 @@ +import os import sys sys.path.append('../') from app.db_manager import connect_db, close_db # noqa @@ -7,6 +8,7 @@ def create_db() -> None: """ Creates tables, using create_db.sql file describing their structures. """ + os.makedirs('csv_tables', exist_ok=True) conn = connect_db() try: with conn.cursor() as cur: diff --git a/app/create_db.sql b/app/create_db.sql index 868ccdb..1b61f73 100644 --- a/app/create_db.sql +++ b/app/create_db.sql @@ -1,6 +1,6 @@ CREATE TABLE IF NOT EXISTS groups ( id serial PRIMARY KEY, - owner bigint NOT NULL UNIQUE CHECK(telegram_id BETWEEN 1 AND 999999999999), + owner bigint NOT NULL UNIQUE CHECK(owner BETWEEN 1 AND 999999999999), token varchar(32) NOT NULL UNIQUE CHECK(LENGTH(token) = 32) ); diff --git a/app/encryption.py b/app/encryption.py index 122b58e..d8f7833 100644 --- a/app/encryption.py +++ b/app/encryption.py @@ -34,4 +34,4 @@ def getting_hash(secure_key: str, salt: str, :param salt: get_salt() :return: hash in hex format """ - return pbkdf2_hmac(hash_algorithm, secure_key.encode('utf-8'), salt.encode('utf-8'), iterations, key_length).hex() \ No newline at end of file + return pbkdf2_hmac(hash_algorithm, secure_key.encode('utf-8'), salt.encode('utf-8'), iterations, key_length).hex() diff --git a/.requirements_external b/requirements_external.txt similarity index 100% rename from .requirements_external rename to requirements_external.txt