Skip to content

Commit

Permalink
postimport.py - just use one session
Browse files Browse the repository at this point in the history
  • Loading branch information
sjib committed Jun 17, 2024
1 parent 86cf192 commit 165631a
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions qgepqwat2ili/postimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def qgep_postimport():
"""


# 31.5.2024 move in extra file and function postimport

# move in extra file and function postimport
# TODO : put this in an "finally" block (or context handler) to make sure it's executed
# even if there's an exception

Expand All @@ -31,25 +30,19 @@ def qgep_postimport():
logger.info("re-enabling symbology triggers (postimport.py)")
post_session.execute("SELECT qgep_sys.create_symbology_triggers();")
logger.info("symbology triggers successfully created! (postimport.py)")
post_session.commit()
post_session.close()

#11.5.2024 add post_session2 - to do add queries for main_cover and main_node as in TEKSI, add to symbology functions
# 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


post_session2 = Session(utils.sqlalchemy.create_engine(), autocommit=False, autoflush=False)

logger.info("Update wastewater structure fk_main_cover")
post_session2.execute("SELECT qgep_od.wastewater_structure_update_fk_main_cover('', True);")
post_session.execute("SELECT qgep_od.wastewater_structure_update_fk_main_cover('', True);")

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

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

post_session2.commit()
post_session2.close()
post_session.commit()
post_session.close()

0 comments on commit 165631a

Please sign in to comment.