Skip to content

Commit

Permalink
Remove unnecessary app_context calls
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Jan 17, 2023
1 parent 35b95b3 commit 091a353
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions test_tools/external_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ def ensure_db():

def ensure_table(schema, name, geo_column):
statement = f'''create table {schema}.{name} ({geo_column} geometry(Geometry, 4326))'''
with app.app_context():
conn_cur = db_util.create_connection_cursor(URI)
db_util.run_statement(f"""CREATE SCHEMA IF NOT EXISTS "{schema}" AUTHORIZATION {settings.LAYMAN_PG_USER}""", conn_cur=conn_cur)
db_util.run_statement(statement, conn_cur=conn_cur)
conn_cur = db_util.create_connection_cursor(URI)
db_util.run_statement(f"""CREATE SCHEMA IF NOT EXISTS "{schema}" AUTHORIZATION {settings.LAYMAN_PG_USER}""", conn_cur=conn_cur)
db_util.run_statement(statement, conn_cur=conn_cur)


def drop_table(schema, name):
statement = f'''drop table if exists {schema}.{name}'''
with app.app_context():
conn_cur = db_util.create_connection_cursor(URI)
db_util.run_statement(statement, conn_cur=conn_cur)
conn_cur = db_util.create_connection_cursor(URI)
db_util.run_statement(statement, conn_cur=conn_cur)

0 comments on commit 091a353

Please sign in to comment.