Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX Text type for SQL Alchemy v1 #157

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions qgepqwat2ili/postimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from geoalchemy2.functions import ST_Force3D
from sqlalchemy.orm import Session
from sqlalchemy.orm.attributes import flag_dirty
from sqlalchemy.sql import text

#31.5.2024 pfade anpassen
#from .. import utils
Expand All @@ -28,33 +29,34 @@ def qgep_postimport():

post_session = Session(utils.sqlalchemy.create_engine(), autocommit=False, autoflush=False)
logger.info("re-enabling symbology triggers (postimport.py)")
post_session.execute("SELECT qgep_sys.create_symbology_triggers();")
post_session.execute(text("SELECT qgep_sys.create_symbology_triggers();"))
logger.info("symbology triggers successfully created! (postimport.py)")

# add queries for main_cover and main_node as in TEKSI, add to symbology functions
# see teksi ww https://github.com/teksi/wastewater/blob/3acfba249866d299f8a22e249d9f1e475fe7b88d/datamodel/app/symbology_functions.sql#L290
# needs delta_1.6.3_functions_update_fk_main_cover_main_wastewater_node.sql
logger.info("Update wastewater structure fk_main_cover")
post_session.execute("SELECT qgep_od.wastewater_structure_update_fk_main_cover('', True);")
post_session.execute(text("SELECT qgep_od.wastewater_structure_update_fk_main_cover('', True);"))

logger.info("Update wastewater structure fk_main_wastewater_node")
post_session.execute("SELECT qgep_od.wastewater_structure_update_fk_main_wastewater_node('', True);"
post_session.execute(text("SELECT qgep_od.wastewater_structure_update_fk_main_wastewater_node('', True));"
)

# add symbology update queries - backporting from tww https://github.com/teksi/wastewater/pull/263
logger.info("update_wastewater_node_symbology for all datasets - please be patient")
post_session.execute("SELECT qgep_od.update_wastewater_node_symbology(NULL, True);")
post_session.execute(text("SELECT qgep_od.update_wastewater_node_symbology(NULL, True);"))

logger.info("update_wastewater_node_symbology for all datasets - please be patient")
logger.info("update_wastewater_structure_label for all datasets - please be patient")
post_session.execute("SELECT qgep_od.update_wastewater_structure_label(NULL, True);")
post_session.execute(text("SELECT qgep_od.update_wastewater_structure_label(NULL, True);"))

logger.info("update_wastewater_node_symbology for all datasets - please be patient")
# update_wastewater_structure_symbology instead of update_wn_symbology_by_overflow (tww)
logger.info("update_wastewater_structure_symbology for all datasets - please be patient")
post_session.execute("SELECT qgep_od.update_wastewater_structure_symbology(NULL, True);")

post_session.execute(text("SELECT qgep_od.update_wastewater_structure_symbology(NULL, True);"))

logger.info("Refresh materialized views")
post_session.execute("SELECT qgep_network.refresh_network_simple();")
post_session.execute(text("SELECT qgep_network.refresh_network_simple();"))

post_session.commit()
post_session.close()
5 changes: 3 additions & 2 deletions qgepqwat2ili/qgep/import_.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from geoalchemy2.functions import ST_Force3D
from sqlalchemy.orm import Session
from sqlalchemy.orm.attributes import flag_dirty
from sqlalchemy.sql import text

from .. import utils
from ..utils.various import logger
Expand All @@ -27,7 +28,7 @@ def qgep_import(precommit_callback=None):

# We also drop symbology triggers as they badly affect performance. This must be done in a separate session as it
# would deadlock other sessions.
pre_session.execute("SELECT qgep_sys.drop_symbology_triggers();")
pre_session.execute(text("SELECT qgep_sys.drop_symbology_triggers();"))
pre_session.commit()
pre_session.close()

Expand All @@ -39,7 +40,7 @@ def qgep_import(precommit_callback=None):

# Allow to insert rows with cyclic dependencies at once, needs data modell version 1.6.2 https://github.com/QGEP/datamodel/pull/235 to work properly
logger.info("SET CONSTRAINTS ALL DEFERRED;")
qgep_session.execute("SET CONSTRAINTS ALL DEFERRED;")
qgep_session.execute(text("SET CONSTRAINTS ALL DEFERRED;"))

def get_vl_instance(vl_table, value):
"""
Expand Down
5 changes: 3 additions & 2 deletions qgepqwat2ili/qgepdss/import_.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from geoalchemy2.functions import ST_Force3D
from sqlalchemy.orm import Session
from sqlalchemy.orm.attributes import flag_dirty
from sqlalchemy.sql import text

from .. import utils
from ..utils.various import logger
Expand All @@ -30,7 +31,7 @@ def qgep_import(precommit_callback=None):
# We also drop symbology triggers as they badly affect performance. This must be done in a separate session as it
# would deadlock other sessions.
logger.info("drop symbology triggers")
pre_session.execute("SELECT qgep_sys.drop_symbology_triggers();")
pre_session.execute(text("SELECT qgep_sys.drop_symbology_triggers();"))
pre_session.commit()
pre_session.close()

Expand All @@ -44,7 +45,7 @@ def qgep_import(precommit_callback=None):

# Allow to insert rows with cyclic dependencies at once, needs data modell version 1.6.2 https://github.com/QGEP/datamodel/pull/235 to work properly
logger.info("SET CONSTRAINTS ALL DEFERRED;")
qgep_session.execute("SET CONSTRAINTS ALL DEFERRED;")
qgep_session.execute(text("SET CONSTRAINTS ALL DEFERRED;"))



Expand Down
5 changes: 3 additions & 2 deletions qgepqwat2ili/qgepsia405/import_.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from geoalchemy2.functions import ST_Force3D
from sqlalchemy.orm import Session
from sqlalchemy.orm.attributes import flag_dirty
from sqlalchemy.sql import text

from .. import utils
from ..utils.various import logger
Expand All @@ -27,7 +28,7 @@ def qgep_import(precommit_callback=None):

# We also drop symbology triggers as they badly affect performance. This must be done in a separate session as it
# would deadlock other sessions.
pre_session.execute("SELECT qgep_sys.drop_symbology_triggers();")
pre_session.execute(text("SELECT qgep_sys.drop_symbology_triggers();"))
pre_session.commit()
pre_session.close()

Expand All @@ -39,7 +40,7 @@ def qgep_import(precommit_callback=None):

# Allow to insert rows with cyclic dependencies at once, needs data modell version 1.6.2 https://github.com/QGEP/datamodel/pull/235 to work properly
logger.info("SET CONSTRAINTS ALL DEFERRED;")
qgep_session.execute("SET CONSTRAINTS ALL DEFERRED;")
qgep_session.execute(text("SET CONSTRAINTS ALL DEFERRED;"))

def get_vl_instance(vl_table, value):
"""
Expand Down
Loading