Created
January 8, 2014 08:18
-
-
Save stefanmonkey/8313476 to your computer and use it in GitHub Desktop.
read image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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