We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,318 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

store image in blob type of mysql

Hi all,

i am new to python
how to store image into database blob using python
please help me for this its urgent

2
Contributors
3
Replies
2 Days
Discussion Span
3 Years Ago
Last Updated
4
Views
rajeshwari_ib
Newbie Poster
8 posts since Dec 2009
Reputation Points: 8
Solved Threads: 0
Skill Endorsements: 0

Hi,

first of all storing a BLOB is very bad design.

But, it would be like this:

blob_value = open('image.jpg', 'rb').read()
sql = 'INSERT INTO Tab1(blob_field) VALUES(%s)'
args = (blob_value, )

cursor.execute (sql, args)
connection.commit()
programmersbook
Junior Poster
121 posts since Nov 2009
Reputation Points: 29
Solved Threads: 30
Skill Endorsements: 0

Hi,

first of all storing a BLOB is very bad design.

But, it would be like this:

blob_value = open('image.jpg', 'rb').read()
sql = 'INSERT INTO Tab1(blob_field) VALUES(%s)'
args = (blob_value, )

cursor.execute (sql, args)
connection.commit()

Thanks yar your code is working fine.

rajeshwari_ib
Newbie Poster
8 posts since Dec 2009
Reputation Points: 8
Solved Threads: 0
Skill Endorsements: 0

thanks yar your code is working fine

rajeshwari_ib
Newbie Poster
8 posts since Dec 2009
Reputation Points: 8
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0592 seconds using 2.64MB