You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@age.apache.org by "theisi (via GitHub)" <gi...@apache.org> on 2024/01/07 17:51:02 UTC

[I] Python driver: Unicode in cypher statements [age]

theisi opened a new issue, #1499:
URL: https://github.com/apache/age/issues/1499

   **Describe the bug**
   A unicode character (code point >128) in a cypher query raises the exception SqlExecutionError: InvalidEscapeSequence.
   
   **How are you accessing AGE (Command line, driver, etc.)?**
   Python driver
   
   **What is the command that caused the error?**
   ```python3
   import age
   ag = age.connect('test_graph', host="/var/run/postgresql", user="postgres")
   ag.execCypher("CREATE (n:Test {name: %s})", params=('abcö',))
   ```
   **Expected behavior**
   Write the unicode string to the database. 
   
   **Environment (please complete the following information):**
   - Release 1.4.0 for PG 14
   
   **Additional context**
   AGE [expects](https://age.apache.org/age-manual/master/intro/types.html) strings encoded with Unicode UTF-16 code points in the form of \uXXXX. However, cursor.mogrify() in age.py returns UTF-8 encoded byte strings. A simple decode, encode sequence can solve the problem for low code points:
   ```python3
   cypher = (
       cursor.mogrify(cypherStmt, params)
       .decode('utf-8')
       .encode('unicode-escape')
       .decode('utf-8')
       .replace('\\x', '\\u00')
   )
   ```
   instead of
   ```python3
   cypher = str(cursor.mogrify(cypherStmt, params))
   cypher = cypher[2:len(cypher)-1]
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Python driver: Unicode in cypher statements [age]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #1499:
URL: https://github.com/apache/age/issues/1499#issuecomment-2105397004

   This issue is stale because it has been open 45 days with no activity. Remove "Abondoned" label or comment or this will be closed in 7 days.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org