I'm trying to upload a file in binary form to PostgreSQL via python
cur.execute("INSERT INTO resultdata(data) VALUES(%s)", (psycopg2.Binary(data),))
So it uploads it in strange way: when i try to view it in db it just spaces
Just I figured that. Try this code:
cur.execute('INSERT INTO resultdata(data) VALUES (%s)', (data,))
cur.fetchall()
Actually, there no use psycopg2.Binary(data) and there already given an imported with psycopg2.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.