Hi everyone,
I am writing a python program using PyADO to add some data to an 'mdb'
database. For example,
filename = UserObjs.mdb
table I am working with = Lines
fields I am working with = ID and Metrics
The 'ID' field is just a number field. The 'Metrics' filed is an OLE object.
In this OLE object assigned in Microsoft Access, I need to include a series
of latitude/longitude numbers as in an array.
The problem I have is that, let's suppose I want to add this array:
[(23.00000,56.58 97),(23.4569,58 ),(244569,60)]. I can add it with no problem to the OLE field, but...when I read the database (SELECT etc..), what I get is something like
this: [ *(*2*3*.*0*,... ) ]
(Note: Here, I used the * to symbolize spaces.)
What I wanted was to store the array as a byte stream. How can I do that?
I'd appreciate any help I could get on this!
Thank you so much!!!
Regards,
Michel
PS: Below is the code I am using to insert / read the data:
****To insert:
*** To read the data
I am writing a python program using PyADO to add some data to an 'mdb'
database. For example,
filename = UserObjs.mdb
table I am working with = Lines
fields I am working with = ID and Metrics
The 'ID' field is just a number field. The 'Metrics' filed is an OLE object.
In this OLE object assigned in Microsoft Access, I need to include a series
of latitude/longitude numbers as in an array.
The problem I have is that, let's suppose I want to add this array:
[(23.00000,56.58 97),(23.4569,58 ),(244569,60)]. I can add it with no problem to the OLE field, but...when I read the database (SELECT etc..), what I get is something like
this: [ *(*2*3*.*0*,... ) ]
(Note: Here, I used the * to symbolize spaces.)
What I wanted was to store the array as a byte stream. How can I do that?
I'd appreciate any help I could get on this!
Thank you so much!!!
Regards,
Michel
PS: Below is the code I am using to insert / read the data:
****To insert:
Code:
import PyADO
import win32com.client
import sys
id_number = raw_input("ID? ")
id_metrics = [(23.00000,56.5897),(23.4569,58),(244569,60)]
conn = win32com.client.Dispatch(r'ADODB.Connection')
DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=C:\msm_test\OLE_project\UserObjs.mdb;'
sql_statement = "INSERT INTO Lines (ID,Metrics) VALUES ('%s','%s');"
%(id_number,id_metrics)
conn.Open(DSN)
conn.Execute(sql_statement)
conn.Close()
Code:
import PyADO
conn =
PyADO.connect(None,user='admin',password='',host=None,database='C:\\msm_test\OLE_project\UserObjs.mdb',provider='Microsoft.Jet.OLEDB.4.0')
curs = conn.cursor()
curs.execute("select * from Lines")
result = curs.fetchall()
descr = curs.description
for row in result:
for col in row:
print col
curs.close()
conn.close()
Comment