# Neo4j-ETL import error from MySql 'Invalid constraint syntax'

**URL:** <https://community.neo4j.com/t/neo4j-etl-import-error-from-mysql-invalid-constraint-syntax/63167>\
**Category:** ETL-Tool\
**Tags:** import\
**Created:** [July 5, 2023, 8:13pm UTC](https://community.neo4j.com/t/neo4j-etl-import-error-from-mysql-invalid-constraint-syntax/63167 "2023-07-05T20:13:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![uczcedx](https://avatars.discourse-cdn.com/v4/letter/u/d2c977/32.png) [@uczcedx](https://community.neo4j.com/u/uczcedx)\
**Post date:** [July 5, 2023, 8:13pm UTC](https://community.neo4j.com/t/neo4j-etl-import-error-from-mysql-invalid-constraint-syntax/63167/1 "2023-07-05T20:13:40Z")

</div>

Hi everyone,

I have tried to import database from Mysql to Neo4j, but there are some error report by logs.

Some keys has properties in MySql as unique, and these properties seems cant be import with syntax error. But I havent find the right place to replace the syntax.

(I have tried Neo4j database 5.9.0 and 4.4.22 mysql 8.0)  
here is my full error:  
_- Direct driver instance 1668837760 created for server address localhost:7687_

_- Running ETL on Neo4j 5.9.0 - ENTERPRISE_

_- Direct driver instance 33419717 created for server address localhost:7687_

_- Starting reading metadataMapping_

_- Creating constraints on nodes_

_- Creating constraint for label Hangar and properties (`h-number`)_

_- Creating constraint for label Airplane and properties (`reg-no`)_

_- Creating constraint for label Plane-Type and properties (model)_

_- Creating constraint for label Pilot and properties (`n-i-n`)_

_- Creating constraint for label Perform-By and properties (rowIndex)_

_- Creating constraint for label Person and properties (`n-i-n`)_

_- Creating constraint for label Service and properties (`s-date`,`reg-no`)_

_- Creating nodes with label Hangar_

_- Creating nodes with label Airplane_

_- Creating nodes with label Plane-Type_

_- Creating nodes with label Pilot_

_- Creating nodes with label Perform-By_

_- Creating nodes with label Person_

_- Creating nodes with label Service_

_- Creating relationships of type SERVICE_

_- Creating relationships of type PERSON_

_- Creating relationships of type AIRPLANE_

_- Creating relationships of type PLANE\_-\_TYPE_

_- Creating relationships of type AIRPLANE_

_- Creating relationships of type HANGAR_

_- Creating relationships of type PERSON_

_- Creating relationships of type OWNED\_-BY-DURING-\_PERIOD_

_- Creating relationships of type FLIGHT_

_- Creating relationships of type CAN\_-BE-WORKED-ON-\_BY_

_- Creating relationships of type CAN\_-BE-PILOTED-\_BY_

_- Data imported with errors. Below the list of errors._

_- For exception ClientException we got the following errors:_

_-_

_Unable to execute Query: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))_

_"CREATE CONSTRAINT ON (n:Hangar) ASSERT n.`h-number` IS UNIQUE"_

_^_

_-_

_Unable to execute Query: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))_

_"CREATE CONSTRAINT ON (n:Airplane) ASSERT n.`reg-no` IS UNIQUE"_

_^_

_-_

_Unable to execute Query: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))_

_"CREATE CONSTRAINT ON (n:`Plane-Type`) ASSERT n.model IS UNIQUE"_

_^_

_-_

_Unable to execute Query: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))_

_"CREATE CONSTRAINT ON (n:Pilot) ASSERT n.`n-i-n` IS UNIQUE"_

_^_

_-_

_Unable to execute Query: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))_

_"CREATE CONSTRAINT ON (n:`Perform-By`) ASSERT n.rowIndex IS UNIQUE"_

_^_

_-_

_Unable to execute Query: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))_

_"CREATE CONSTRAINT ON (n:Person) ASSERT n.`n-i-n` IS UNIQUE"_

_^_

_-_

_Unable to execute Query: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))_

_"CREATE CONSTRAINT ON (n:Service) ASSERT (n.`s-date`,n.`reg-no`) IS NODE KEY"_

---

<div class="post-metadata">

**Author:** ![jennifer\_reif](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/jennifer_reif/32/8061_2.png) [@jennifer\_reif](https://community.neo4j.com/u/jennifer_reif)\
**Post date:** [July 19, 2023, 11:11pm UTC](https://community.neo4j.com/t/neo4j-etl-import-error-from-mysql-invalid-constraint-syntax/63167/2 "2023-07-19T23:11:35Z")

</div>

Hello! The syntax for creating constraints changed between Neo4j version 4 and version 5, and I don't believe the ETL tool supports Neo4j 5.0. So that's why the tool does not recognize the updated constraint syntax for that version. Could you try to import into a Neo4j 4.4 database?

---

<div class="post-metadata">

**Author:** ![uczcedx](https://avatars.discourse-cdn.com/v4/letter/u/d2c977/32.png) [@uczcedx](https://community.neo4j.com/u/uczcedx)\
**Post date:** [July 24, 2023, 3:49pm UTC](https://community.neo4j.com/t/neo4j-etl-import-error-from-mysql-invalid-constraint-syntax/63167/3 "2023-07-24T15:49:05Z")

</div>

Thank you. I have tried version 4.4.0, the error turns into  
_'unable to execute statement: Cannot merge the following node because of null property value for 'n-i-n': (:Person {n-i-n: null})'_  
\*Person is the table and n-i-n is the PK  
Maybe the error is due to the PK characteristic?

Here is the full log:  
_- Reading options from file C:\Users\Lenovo\AppData\Local\Temp\import-tool-options.json._  
_- Reading metadata mapping from file: C:\Users\Lenovo\AppData\Local\Temp/mysql\_ans\_ex\_ans\_ex\_mapping.json_  
_- Direct driver instance 1668837760 created for server address localhost:7687_  
_- Running ETL on Neo4j 4.3.22 - ENTERPRISE_  
_- Direct driver instance 764826684 created for server address localhost:7687_  
_- Starting reading metadataMapping_  
_- Creating constraints on nodes_  
_- Creating constraint for label Hangar and properties (`h-number`)_  
_- Creating constraint for label Airplane and properties (`reg-no`)_  
_- Creating constraint for label Plane-Type and properties (model)_  
_- Creating constraint for label Pilot and properties (`n-i-n`)_  
_- Creating constraint for label Perform-By and properties (rowIndex)_  
_- Creating constraint for label Person and properties (`n-i-n`)_  
_- Creating constraint for label Service and properties (`s-date`,`reg-no`)_  
_- Creating nodes with label Hangar_  
_- Creating nodes with label Airplane_  
_- Creating nodes with label Plane-Type_  
_- Creating nodes with label Pilot_  
_- Creating nodes with label Perform-By_  
_- Creating nodes with label Person_  
_- Creating nodes with label Service_  
_- Creating relationships of type SERVICE_  
_- Creating relationships of type PERSON_  
_- Creating relationships of type AIRPLANE_  
_- Creating relationships of type PLANE\_-\_TYPE_  
_- Creating relationships of type AIRPLANE_  
_- Creating relationships of type HANGAR_  
_- Creating relationships of type PERSON_  
_- Creating relationships of type OWNED\_-BY-DURING-\_PERIOD_  
_- Creating relationships of type FLIGHT_  
_- Creating relationships of type CAN\_-BE-WORKED-ON-\_BY_  
_- Creating relationships of type CAN\_-BE-PILOTED-\_BY_  
_- Data imported with errors. Below the list of errors._  
_- For exception ClientException we got the following errors:_  
\*- \*  
_Unable to execute Query: An equivalent constraint already exists, 'Constraint( id=4, name='constraint\_1933e5a', type='UNIQUENESS', schema=(:Hangar {h-number}), ownedIndex=3 )'._  
\*- \*  
_Unable to execute Query: An equivalent constraint already exists, 'Constraint( id=6, name='constraint\_5337d473', type='UNIQUENESS', schema=(:Airplane {reg-no}), ownedIndex=5 )'._  
\*- \*  
_Unable to execute Query: An equivalent constraint already exists, 'Constraint( id=8, name='constraint\_78a00635', type='UNIQUENESS', schema=(:Plane-Type {model}), ownedIndex=7 )'._  
\*- \*  
_Unable to execute Query: An equivalent constraint already exists, 'Constraint( id=10, name='constraint\_6ffb6489', type='UNIQUENESS', schema=(:Pilot {n-i-n}), ownedIndex=9 )'._  
\*- \*  
_Unable to execute Query: An equivalent constraint already exists, 'Constraint( id=12, name='constraint\_6ed71327', type='UNIQUENESS', schema=(:Perform-By {rowIndex}), ownedIndex=11 )'._  
\*- \*  
_Unable to execute Query: An equivalent constraint already exists, 'Constraint( id=14, name='constraint\_8aff69f6', type='UNIQUENESS', schema=(:Person {n-i-n}), ownedIndex=13 )'._  
\*- \*  
_Unable to execute Query: An equivalent constraint already exists, 'Constraint( id=16, name='constraint\_8d8c5c89', type='NODE KEY', schema=(:Service {s-date, reg-no}), ownedIndex=15 )'._  
\*- \*  
_Unable to execute statement: Cannot merge the following node because of null property value for 'h-number': (:Hangar {h-number: null})_  
\*- \*  
_Process failed Transaction can't be committed. It has been rolled back either because of an error or explicit termination_  
\*- \*  
_Unable to execute statement: Cannot merge the following node because of null property value for 'reg-no': (:Airplane {reg-no: null})_  
_- Closing driver instance 764826684_  
_- Closing connection pool towards localhost:7687_

---

<div class="post-metadata">

**Author:** ![jennifer\_reif](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/jennifer_reif/32/8061_2.png) [@jennifer\_reif](https://community.neo4j.com/u/jennifer_reif)\
**Post date:** [July 31, 2023, 9:52pm UTC](https://community.neo4j.com/t/neo4j-etl-import-error-from-mysql-invalid-constraint-syntax/63167/4 "2023-07-31T21:52:13Z")

</div>

It sounds like there is a n-i-n value that is null in the data set. Since that field is a primary key, it can't be null, which is why the import errors out. If you can review your data and ensure there is some type of value for every n-i-n entry, then that should fix that one!
