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

2025-01-23-patch-fk_provider_check #191

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 12 additions & 10 deletions qgepqwat2ili/utils/ili2db.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def check_identifier_null():
("zone"),
]:
cursor.execute(
f"SELECT COUNT(obj_id) FROM qgep_od.{notsubclass} WHERE identifier is null;"
f"SELECT COUNT(obj_id) FROM qgep_od.{notsubclass} WHERE identifier is null or identifier = '';"
)
# use cursor.fetchone()[0] instead of cursor.rowcount
# add variable and store result of cursor.fetchone()[0] as the next call will give None value instead of count https://pynative.com/python-cursor-fetchall-fetchmany-fetchone-to-read-rows-from-table/
Expand Down Expand Up @@ -198,7 +198,9 @@ def check_fk_owner_null():
# SIA405 Abwasser
("wastewater_structure"),
]:
cursor.execute(f"SELECT COUNT(obj_id) FROM qgep_od.{notsubclass} WHERE fk_owner is null;")
cursor.execute(
f"SELECT COUNT(obj_id) FROM qgep_od.{notsubclass} WHERE fk_owner is null or fk_owner = '';"
)
# use cursor.fetchone()[0] instead of cursor.rowcount
# add variable and store result of cursor.fetchone()[0] as the next call will give None value instead of count https://pynative.com/python-cursor-fetchall-fetchmany-fetchone-to-read-rows-from-table/
class_fk_owner_count = int(cursor.fetchone()[0])
Expand All @@ -217,7 +219,7 @@ def check_fk_owner_null():
missing_fk_owner_count = missing_fk_owner_count + class_fk_owner_count

# add for testing
logger.info(f"missing_fk_owner_count : {missing_fk_owner_count}")
logger.debug(f"missing_fk_owner_count : {missing_fk_owner_count}")

if missing_fk_owner_count == 0:
check_fk_owner_null = True
Expand Down Expand Up @@ -246,7 +248,7 @@ def check_fk_operator_null():
("wastewater_structure"),
]:
cursor.execute(
f"SELECT COUNT(obj_id) FROM qgep_od.{notsubclass} WHERE fk_operator is null;"
f"SELECT COUNT(obj_id) FROM qgep_od.{notsubclass} WHERE fk_operator is null or fk_operator = '';"
)
# use cursor.fetchone()[0] instead of cursor.rowcount
logger.info(
Expand All @@ -258,7 +260,7 @@ def check_fk_operator_null():
else:
missing_fk_operator_count = missing_fk_operator_count + int(cursor.fetchone()[0])
# add for testing
logger.info(f"missing_fk_operator_count : {missing_fk_operator_count}")
logger.debug(f"missing_fk_operator_count : {missing_fk_operator_count}")

if missing_fk_operator_count == 0:
logger.info("OK: all mandatory fk_operator set in qgep_od!")
Expand Down Expand Up @@ -324,7 +326,7 @@ def check_fk_dataowner_null():
("zone"),
]:
cursor.execute(
f"SELECT COUNT(obj_id) FROM qgep_od.{notsubclass} WHERE fk_dataowner is null;"
f"SELECT COUNT(obj_id) FROM qgep_od.{notsubclass} WHERE fk_dataowner is null or fk_dataowner = '';"
)
# use cursor.fetchone()[0] instead of cursor.rowcount
# add variable and store result of cursor.fetchone()[0] as the next call will give None value instead of count https://pynative.com/python-cursor-fetchall-fetchmany-fetchone-to-read-rows-from-table/
Expand All @@ -345,7 +347,7 @@ def check_fk_dataowner_null():
missing_fk_dataowner_count = missing_fk_dataowner_count + class_fk_dataowner_count

# add for testing
logger.info(f"missing_fk_dataowner_count : {missing_fk_dataowner_count}")
logger.debug(f"missing_fk_dataowner_count : {missing_fk_dataowner_count}")

if missing_fk_dataowner_count == 0:
logger.info("OK: all mandatory fk_dataowner set in qgep_od!")
Expand Down Expand Up @@ -411,7 +413,7 @@ def check_fk_provider_null():
("zone"),
]:
cursor.execute(
f"SELECT COUNT(obj_id) FROM qgep_od.{notsubclass} WHERE fk_provider is null;"
f"SELECT COUNT(obj_id) FROM qgep_od.{notsubclass} WHERE fk_provider is null or fk_provider = '';"
)
# use cursor.fetchone()[0] instead of cursor.rowcount
# add variable and store result of cursor.fetchone()[0] as the next call will give None value instead of count https://pynative.com/python-cursor-fetchall-fetchmany-fetchone-to-read-rows-from-table/
Expand All @@ -420,7 +422,7 @@ def check_fk_provider_null():
# f"Number of datasets in class '{notsubclass}' without fk_provider : {cursor.fetchone()[0]}"
# )
logger.info(
f"Number of datasets in class '{notsubclass}' without fk_dataowner : {class_fk_provider_count}"
f"Number of datasets in class '{notsubclass}' without fk_provider : {class_fk_provider_count}"
)

# if cursor.fetchone() is None:
Expand All @@ -431,7 +433,7 @@ def check_fk_provider_null():
missing_fk_provider_count = missing_fk_provider_count + class_fk_provider_count

# add for testing
logger.info(f"missing_fk_provider_count : {missing_fk_provider_count}")
logger.debug(f"missing_fk_provider_count : {missing_fk_provider_count}")

if missing_fk_provider_count == 0:
logger.info("OK: all mandatory fk_provider set in qgep_od!")
Expand Down