Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ERREUR: une valeur NULL viole la contrainte NOT NULL de la colonne « abwasserbauwerkref » dans la relation « bauwerksteil » #900

@ponceta

Description

@ponceta

Describe the bug
When exporting my data to DSS I get an error message :

Une erreur est survenue lors de l'exécution du code Python : 

sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) ERREUR:  une valeur NULL viole la contrainte NOT NULL de la colonne « abwasserbauwerkref » dans la relation « bauwerksteil » DETAIL:  La ligne en échec contient (254160, null, ch176dc9SP001771, null, null). [SQL: INSERT INTO pg2ili_dss.bauwerksteil (t_id, bemerkung, bezeichnung, instandstellung, abwasserbauwerkref) VALUES (%(t_id__0)s, %(bemerkung__0)s, %(bezeichnung__0)s, %(instandstellung__0)s, %(abwasserbauwerkref__0)s), (%(t_id__1)s, %(bemerkung__1)s, %(b ... 113209 characters truncated ... )s, %(bemerkung__999)s, %(bezeichnung__999)s, %(instandstellung__999)s, %(abwasserbauwerkref__999)s)] [parameters: {'abwasserbauwerkref__0': 53777, 't_id__0': 254159, 'bemerkung__0': None, 'bezeichnung__0': 'ch176dc9SP006971', 'instandstellung__0': None, 'abwasserbauwerkref__1': None, 't_id__1': 254160, 'bemerkung__1': None, 'bezeichnung__1': 'ch176dc9SP001771', 'instandstellung__1': None, 'abwasserbauwerkref__2': None, 't_id__2': 254161, 'bemerkung__2': None, 'bezeichnung__2': 'ch176dc9SP001772', 'instandstellung__2': None, 'abwasserbauwerkref__3': 57499, 't_id__3': 254162, 'bemerkung__3': None, 'bezeichnung__3': 'ch176dc9SP001773', 'instandstellung__3': None, 'abwasserbauwerkref__4': 69401, 't_id__4': 254163, 'bemerkung__4': None, 'bezeichnung__4': 'ch176dc9SP001774', 'instandstellung__4': None, 'abwasserbauwerkref__5': 58062, 't_id__5': 254164, 'bemerkung__5': None, 'bezeichnung__5': 'ch176dc9SP001775', 'instandstellung__5': None, 'abwasserbauwerkref__6': 54131, 't_id__6': 254165, 'bemerkung__6': None, 'bezeichnung__6': 'ch176dc9SP001776', 'instandstellung__6': None, 'abwasserbauwerkref__7': 58959, 't_id__7': 254166, 'bemerkung__7': None, 'bezeichnung__7': 'ch176dc9SP001778', 'instandstellung__7': None, 'abwasserbauwerkref__8': None, 't_id__8': 254167, 'bemerkung__8': None, 'bezeichnung__8': 'ch176dc9SP000894', 'instandstellung__8': None, 'abwasserbauwerkref__9': 58075, 't_id__9': 254168, 'bemerkung__9': None, 'bezeichnung__9': 'ch176dc9SP001779', 'instandstellung__9': None ... 4900 parameters truncated ... 'abwasserbauwerkref__990': 64679, 't_id__990': 255149, 'bemerkung__990': None, 'bezeichnung__990': 'ch176dc9SP000489', 'instandstellung__990': None, 'abwasserbauwerkref__991': 70695, 't_id__991': 255150, 'bemerkung__991': None, 'bezeichnung__991': 'ch176dc9SP000490', 'instandstellung__991': None, 'abwasserbauwerkref__992': 66044, 't_id__992': 255151, 'bemerkung__992': None, 'bezeichnung__992': 'ch176dc9SP000491', 'instandstellung__992': None, 'abwasserbauwerkref__993': 71151, 't_id__993': 255152, 'bemerkung__993': None, 'bezeichnung__993': 'ch176dc9SP000492', 'instandstellung__993': None, 'abwasserbauwerkref__994': 70696, 't_id__994': 255153, 'bemerkung__994': None, 'bezeichnung__994': 'ch176dc9SP000493', 'instandstellung__994': None, 'abwasserbauwerkref__995': 66045, 't_id__995': 255154, 'bemerkung__995': None, 'bezeichnung__995': 'ch176dc9SP000495', 'instandstellung__995': None, 'abwasserbauwerkref__996': 64680, 't_id__996': 255155, 'bemerkung__996': None, 'bezeichnung__996': 'ch176dc9SP000496', 'instandstellung__996': None, 'abwasserbauwerkref__997': 64684, 't_id__997': 255156, 'bemerkung__997': None, 'bezeichnung__997': 'ch176dc9SP000497', 'instandstellung__997': None, 'abwasserbauwerkref__998': 65020, 't_id__998': 255157, 'bemerkung__998': None, 'bezeichnung__998': 'ch176dc9SP000498', 'instandstellung__998': None, 'abwasserbauwerkref__999': 64685, 't_id__999': 255158, 'bemerkung__999': None, 'bezeichnung__999': 'ch176dc9SP000499', 'instandstellung__999': None}] (Background on this error at: https://sqlalche.me/e/20/gkpj) 
Traceback (most recent call last):
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 2120, in _exec_insertmany_context
    dialect.do_execute(
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\engine\default.py", line 919, in do_execute
    cursor.execute(statement, parameters)
psycopg2.errors.NotNullViolation: ERREUR:  une valeur NULL viole la contrainte NOT NULL de la colonne « abwasserbauwerkref » dans la relation « bauwerksteil »
DETAIL:  La ligne en échec contient (254160, null, ch176dc9SP001771, null, null).


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users/pulpoar/AppData/Roaming/QGIS/QGIS3\profiles\pulpoar_qgep/python/plugins\qgepplugin\qgepqwat2ili\qgepqwat2ili\gui\__init__.py", line 690, in action_do_export
    qgep_export_dss(
  File "C:\Users/pulpoar/AppData/Roaming/QGIS/QGIS3\profiles\pulpoar_qgep/python/plugins\qgepplugin\qgepqwat2ili\qgepqwat2ili\qgepdss\export.py", line 2285, in qgep_export_dss
    qgep_export_utils.export_access_aid()
  File "C:\Users/pulpoar/AppData/Roaming/QGIS/QGIS3\profiles\pulpoar_qgep/python/plugins\qgepplugin\qgepqwat2ili\qgepqwat2ili\utils\qgep_export_utils.py", line 931, in export_access_aid
    self.abwasser_session.flush()
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\orm\session.py", line 4296, in flush
    self._flush(objects)
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\orm\session.py", line 4431, in _flush
    with util.safe_reraise():
         ^^^^^^^^^^^^^^^^^^^
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\orm\session.py", line 4392, in _flush
    flush_context.execute()
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\orm\unitofwork.py", line 466, in execute
    rec.execute(self)
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\orm\unitofwork.py", line 642, in execute
    util.preloaded.orm_persistence.save_obj(
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\orm\persistence.py", line 93, in save_obj
    _emit_insert_statements(
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\orm\persistence.py", line 1048, in _emit_insert_statements
    result = connection.execute(
             ^^^^^^^^^^^^^^^^^^^
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 1422, in execute
    return meth(
           ^^^^^
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\sql\elements.py", line 514, in _execute_on_connection
    return connection._execute_clauseelement(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 1644, in _execute_clauseelement
    ret = self._execute_context(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 1848, in _execute_context
    return self._exec_insertmany_context(dialect, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 2128, in _exec_insertmany_context
    self._handle_dbapi_exception(
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 2357, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 2120, in _exec_insertmany_context
    dialect.do_execute(
  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\sqlalchemy\engine\default.py", line 919, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) ERREUR:  une valeur NULL viole la contrainte NOT NULL de la colonne « abwasserbauwerkref » dans la relation « bauwerksteil »
DETAIL:  La ligne en échec contient (254160, null, ch176dc9SP001771, null, null).

[SQL: INSERT INTO pg2ili_dss.bauwerksteil (t_id, bemerkung, bezeichnung, instandstellung, abwasserbauwerkref) VALUES (%(t_id__0)s, %(bemerkung__0)s, %(bezeichnung__0)s, %(instandstellung__0)s, %(abwasserbauwerkref__0)s), (%(t_id__1)s, %(bemerkung__1)s, %(b ... 113209 characters truncated ... )s, %(bemerkung__999)s, %(bezeichnung__999)s, %(instandstellung__999)s, %(abwasserbauwerkref__999)s)]
[parameters: {'abwasserbauwerkref__0': 53777, 't_id__0': 254159, 'bemerkung__0': None, 'bezeichnung__0': 'ch176dc9SP006971', 'instandstellung__0': None, 'abwasserbauwerkref__1': None, 't_id__1': 254160, 'bemerkung__1': None, 'bezeichnung__1': 'ch176dc9SP001771', 'instandstellung__1': None, 'abwasserbauwerkref__2': None, 't_id__2': 254161, 'bemerkung__2': None, 'bezeichnung__2': 'ch176dc9SP001772', 'instandstellung__2': None, 'abwasserbauwerkref__3': 57499, 't_id__3': 254162, 'bemerkung__3': None, 'bezeichnung__3': 'ch176dc9SP001773', 'instandstellung__3': None, 'abwasserbauwerkref__4': 69401, 't_id__4': 254163, 'bemerkung__4': None, 'bezeichnung__4': 'ch176dc9SP001774', 'instandstellung__4': None, 'abwasserbauwerkref__5': 58062, 't_id__5': 254164, 'bemerkung__5': None, 'bezeichnung__5': 'ch176dc9SP001775', 'instandstellung__5': None, 'abwasserbauwerkref__6': 54131, 't_id__6': 254165, 'bemerkung__6': None, 'bezeichnung__6': 'ch176dc9SP001776', 'instandstellung__6': None, 'abwasserbauwerkref__7': 58959, 't_id__7': 254166, 'bemerkung__7': None, 'bezeichnung__7': 'ch176dc9SP001778', 'instandstellung__7': None, 'abwasserbauwerkref__8': None, 't_id__8': 254167, 'bemerkung__8': None, 'bezeichnung__8': 'ch176dc9SP000894', 'instandstellung__8': None, 'abwasserbauwerkref__9': 58075, 't_id__9': 254168, 'bemerkung__9': None, 'bezeichnung__9': 'ch176dc9SP001779', 'instandstellung__9': None ... 4900 parameters truncated ... 'abwasserbauwerkref__990': 64679, 't_id__990': 255149, 'bemerkung__990': None, 'bezeichnung__990': 'ch176dc9SP000489', 'instandstellung__990': None, 'abwasserbauwerkref__991': 70695, 't_id__991': 255150, 'bemerkung__991': None, 'bezeichnung__991': 'ch176dc9SP000490', 'instandstellung__991': None, 'abwasserbauwerkref__992': 66044, 't_id__992': 255151, 'bemerkung__992': None, 'bezeichnung__992': 'ch176dc9SP000491', 'instandstellung__992': None, 'abwasserbauwerkref__993': 71151, 't_id__993': 255152, 'bemerkung__993': None, 'bezeichnung__993': 'ch176dc9SP000492', 'instandstellung__993': None, 'abwasserbauwerkref__994': 70696, 't_id__994': 255153, 'bemerkung__994': None, 'bezeichnung__994': 'ch176dc9SP000493', 'instandstellung__994': None, 'abwasserbauwerkref__995': 66045, 't_id__995': 255154, 'bemerkung__995': None, 'bezeichnung__995': 'ch176dc9SP000495', 'instandstellung__995': None, 'abwasserbauwerkref__996': 64680, 't_id__996': 255155, 'bemerkung__996': None, 'bezeichnung__996': 'ch176dc9SP000496', 'instandstellung__996': None, 'abwasserbauwerkref__997': 64684, 't_id__997': 255156, 'bemerkung__997': None, 'bezeichnung__997': 'ch176dc9SP000497', 'instandstellung__997': None, 'abwasserbauwerkref__998': 65020, 't_id__998': 255157, 'bemerkung__998': None, 'bezeichnung__998': 'ch176dc9SP000498', 'instandstellung__998': None, 'abwasserbauwerkref__999': 64685, 't_id__999': 255158, 'bemerkung__999': None, 'bezeichnung__999': 'ch176dc9SP000499', 'instandstellung__999': None}]
(Background on this error at: https://sqlalche.me/e/20/gkpj)


Version de Python : 3.12.11 (main, Jun 17 2025, 13:41:12) [MSC v.1943 64 bit (AMD64)] 
Version de QGIS : 3.40.8-Bratislava Bratislava, efaf8952e0 

Chemin Python :
C:/OSGeo4W/apps/qgis-ltr/./python
C:/Users/pulpoar/AppData/Roaming/QGIS/QGIS3\profiles\pulpoar_qgep/python
C:/Users/pulpoar/AppData/Roaming/QGIS/QGIS3\profiles\pulpoar_qgep/python/plugins
C:/OSGeo4W/apps/qgis-ltr/./python/plugins
C:\OSGeo4W\bin\python312.zip
C:\OSGeo4W\apps\Python312\DLLs
C:\OSGeo4W\apps\Python312\Lib
C:\OSGeo4W\bin
C:\Users\pulpoar\AppData\Roaming\Python\Python312\site-packages
C:\OSGeo4W\apps\Python312
C:\OSGeo4W\apps\Python312\Lib\site-packages
C:/Users/pulpoar/AppData/Roaming/QGIS/QGIS3\profiles\pulpoar_qgep/python
C:\OSGeo4W\apps\Python312\Lib\site-packages\setuptools\_vendor
//pully.ch/APP/Pul_DTSI/DTSI/Projets_QGIS/QGEP_Cadastre/project
C:\Users/pulpoar/AppData/Roaming/QGIS/QGIS3\profiles\pulpoar_qgep/python/plugins\qgepplugin\qgepqwat2ili\qgepqwat2ili\gui\..\..
.

To Reproduce
Exact steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots / data
If applicable, add screenshots or data to help explain your problem.

Desktop (please complete the following information):

  • QGEP plugin version
  • QGEP datamodel version
  • QGEP project file version
  • QGIS Version
  • OS

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions