R
romap
Hello.
This is the full work version.
Do yuo have:
- Pyton, PostgreSQL, Psycopg2
- PostgreSQL dababase named "MyDATABASE" with table named "phonebook"
- Table "phonebook" have this columns: "lastname" [TEXT datatype] and
"c2image" [BYTEA datatype]
- Do you have an jpeg file named "sun.jpg" on c:/
Open db connection
Write image on database (binary data on bytea column)
Read image from database and write to a file
Close db connection
This is the full work version.
Do yuo have:
- Pyton, PostgreSQL, Psycopg2
- PostgreSQL dababase named "MyDATABASE" with table named "phonebook"
- Table "phonebook" have this columns: "lastname" [TEXT datatype] and
"c2image" [BYTEA datatype]
- Do you have an jpeg file named "sun.jpg" on c:/
Open db connection
Write image on database (binary data on bytea column)
Read image from database and write to a file
cursor = conn.cursor()
cursor.execute("SELECT (c2image) FROM phonebook WHERE lastname='MyPICTURENAME';")
mypic2 = cursor.fetchone()
open('c:/copyofsun.jpg', 'wb').write(str(mypic2[0]))
Close db connection