Skip to content

Instantly share code, notes, and snippets.

@stefanmonkey
Created January 8, 2014 08:18
Show Gist options
  • Save stefanmonkey/8313476 to your computer and use it in GitHub Desktop.
Save stefanmonkey/8313476 to your computer and use it in GitHub Desktop.
read image
#!/usr/bin/python
# -*- coding: utf-8 -*-
import MySQLdb as mdb
def writeImage(data):
fout = open('woman2.jpg', 'wb')
with fout:
fout.write(data)
con = mdb.connect('localhost', 'testuser', 'test623', 'testdb')
with con:
cur = con.cursor()
cur.execute("SELECT Data FROM Images WHERE Id=1")
data = cur.fetchone()[0]
writeImage(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment