Search code examples
pythonpython-3.xpsycopg2psycopg

I don't want psycopg2 to escape new line character (\n) in query result


I have some records data with \n. When I do a SELECT query using psycopg2 the result comes with \n escaped like this \\n. I want the result have literal \n in order to use splitlines().


Solution

  • The point is that values were edited with pgadmin3 (incorrectly, the correct way is shift+enter to add a new line). I asked the user to use phppgadmin (easier for him, multiline fields are edited with textarea control) and now everything is working properly.

    So pyscopg2 WORKS fine, I'm sorry to thought it was the culprit.

    He was putting literals \n in order to put new lines.