[DB-SIG] Re: DB-SIG Digest, Vol 17, Issue 12

General Electronics,Phaltan str_kbs at sancharnet.in
Sat Sep 11 05:33:26 CEST 2004

here is short code which i am using.

from mx.ODBC.Windows import *
import Image                                    #This is PIL Image Library
For Python

db = DriverConnect('DSN=ImageData;UID="";PWD=""') #Connect To ODBC

#Now Load Image From JPG file

img = Image.open("myimg.jpg")        #Image Object
bx = (0,0,56,57)                                #Box Object
eimg = img.crop(bx)                         #Image Cropped
estrng = eimg.tostring()                    #Image String This is somewhat
9000 bytes long
mylen = len(estrng)                         #Length Of Image string

#Now ODBC DSN is Visual FoxPro Database and Table is imgdata (user defined)
#file structure for the imgdata is as follows -
# Field         Type          Length
#SRL_NO    Numeric     6
#IMG_STN  General                        #Where I want to store estrng

mycursor = db.cursor()                    #Create Cursor to operate SQL
mycursor.executedirect('insert into imgdata (SRL_NO,IMG_STN) Value (?,?)

#Now Read Info From database
mycursor.executedirect('select * from imgdata')    #Read SQL
dta = mycursor.fetchone()                                      #Prepare
ex_estrng = dta[1]                                                #IMG_STN
Field Stores Data here
if  mylen == len(ex_estrng):
        print "Good"
        print "Bad"                                                #This is
what i am getting

Please help me how can I make definatly store data as is in IMG_STN and
retrive as Is.

Arvind Sidhaye

----- Original Message -----
From: <db-sig-request at python.org>
To: <db-sig at python.org>
Sent: Thursday, August 19, 2004 3:30 PM
Subject: DB-SIG Digest, Vol 17, Issue 12

> Send DB-SIG mailing list submissions to
> db-sig at python.org
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.python.org/mailman/listinfo/db-sig
> or, via email, send a message with subject or body 'help' to
> db-sig-request at python.org
> You can reach the person managing the list at
> db-sig-owner at python.org
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of DB-SIG digest..."


> Today's Topics:
>    1. RE: MS SQL Server and odbc getting 'None'
>       (Carey David SSgt 109CF/SCBJ)
>    2. db module wrapper (Randall Smith)
>    3. Re: db module wrapper (Ian Bicking)

More information about the DB-SIG mailing list