Skip to content

Commit 02b7493

Browse files
committed
Fix import
1 parent 5826c2b commit 02b7493

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pum/utils/execute_sql.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from psycopg import Connection, Cursor
55
from psycopg.errors import SyntaxError
66

7-
from .exceptions import PumSqlException
7+
from ..exceptions import PumSqlException
88
import re
99

1010
logger = logging.getLogger(__name__)
@@ -34,21 +34,22 @@ def execute_sql(
3434
f"Executing SQL from file: {sql} with parameters: {parameters}",
3535
)
3636
with open(sql) as file:
37-
sql_content = file.read()
37+
sql_content = file.read()
3838
if parameters:
3939
for key, value in parameters.items():
40-
sql_content = sql_content.replace(f'{{{{ {key} }}}}', str(value))
40+
sql_content = sql_content.replace(f"{{{{ {key} }}}}", str(value))
4141
sql_code = sql_content
4242
else:
4343
sql_code = sql_content
44+
4445
def split_sql_statements(sql):
4546
pattern = r'(?:[^;\'"]|\'[^\']*\'|"[^"]*")*;'
4647
matches = re.finditer(pattern, sql, re.DOTALL)
4748
statements = []
4849
last_end = 0
4950
for match in matches:
5051
end = match.end()
51-
statements.append(sql[last_end:end - 1].strip())
52+
statements.append(sql[last_end : end - 1].strip())
5253
last_end = end
5354
if last_end < len(sql):
5455
statements.append(sql[last_end:].strip())
@@ -62,7 +63,7 @@ def split_sql_statements(sql):
6263
cursor.execute(statement)
6364

6465
except SyntaxError as e:
65-
logger.debug(f'Error executing SQL: {sql_code}')
66+
logger.debug(f"Error executing SQL: {sql_code}")
6667
raise PumSqlException(f"SQL execution failed for the following code: {sql} {e}") from e
6768
if commit:
6869
conn.commit()

0 commit comments

Comments
 (0)