From 36c0af1ae252fb11bbe652fc05d6ea04c5554ecf Mon Sep 17 00:00:00 2001 From: Kotorkovsciy Date: Wed, 10 Aug 2022 19:14:20 +0300 Subject: [PATCH] correcting sql_data --- scripts/sql_data.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/sql_data.py b/scripts/sql_data.py index afca7cf..172f892 100644 --- a/scripts/sql_data.py +++ b/scripts/sql_data.py @@ -1,4 +1,5 @@ -from os import getenv +from os import getenv, mkdir +from os.path import exists from dotenv import load_dotenv from psycopg2 import connect from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT @@ -230,6 +231,8 @@ async def deleteJokes(self): async def dump(self, user_id): """Дамп бд""" + if not exists("sql/"): + mkdir("sql/") self.__open__() self.cursor.execute('SELECT * FROM users') with open(f"sql\dump_users_{user_id}.sql", "w", encoding='utf 8') as file: