I use Python to connect to my postgresql data base like this:
conn=psycopg2.connect(database="fedour", user="fedpur", password="***", host="127.0.0.1", port="5432")
No problem for that.
But when I make a query and I want to print the cursor I have something like this:
"Fran\xc3\xa7ois" instead of "François" and it cause problem when I want to create a XML document with this. I thkink is come from my encodage, but I found any solution. I try to encode('utf-8') but doesn't work.
I have also seen something like this, but its only for mySQL
MySQLdb.connect(charset='utf8', init_command='SET NAMES UTF8')
Can you help me ? Thanks
The psycopg2-binary package is meant for beginners to start playing with Python and PostgreSQL without the need to meet the build requirements. If you are the maintainer of a published package depending on psycopg2 you shouldn't use psycopg2-binary as a module dependency.
Psycopg allows asynchronous interaction with other database sessions using the facilities offered by PostgreSQL commands LISTEN and NOTIFY.
Python 3 module for PostgreSQL psycopg is a PostgreSQL database adapter for the Python3 programming language (just like pygresql and popy.) This is version 2, a complete rewrite of the original code to provide new-style classes for connection and cursor objects and other sweet candies.
Make sure you're using the right encodind by running: print conn.encoding
, and if you need, you can set the right encoding by conn.set_client_encoding('UNICODE')
, or conn.set_client_encoding('UTF8')
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With