[python-win32] Embedding an OLE object through ADO. How..?
Uffe Wassmann
hadaqada at gmail.com
Mon Aug 7 11:53:51 CEST 2006
My employer would like an Access database updated.
It has been made partly by hand before, but I thought it should be
automated, as 99% of the relevant information is available by looking
at the file system and parsing some text files.
In the past week this has led me to learn something about python
dictionaries, tuples, lists, classes, expected syntax, WinPython (got
that book here, ya :), and I'm at the point where I've created a new
database with nice relations between the tables and all information
available.
Except the preview pictures.
Now, other db's can take binary things beyond 1kb without coughing,
but he needs it to be Access for the customers' sake. So, ADO and
creation of an embedded OLE object it is, I'm thinking.
Visual Basic guides inherits the OLE object from a base class and uses
the creation method from it.
So my question is.. where do I get this method and object from in
WinPython? It is probably simple, but I can't find it :]
I use Python 2.4, WinPython, and have run makepy on DAO and ADO
libraries. I did -not- attempt to parse makepy's generated files
beyond skimming it :]
_____________________________________________________________
Code:
_____________________________________________________________
import win32com.client
from pprint import pprint
adoConn = win32com.client.Dispatch('ADODB.Connection')
adoConn.Open('MS Access-database')
adoRS=win32com.client.Dispatch('ADODB.Recordset')
adoConn.Execute("DROP TABLE Preview")
adoConn.Execute("CREATE TABLE Preview (SceneId int, Preview OLEObject)")
adoRS.Open("[Preview]",adoConn, 1, 3) # 1=adOpenKeyset, 3=adLockOptimistic
adoRS.AddNew()
adoRS.Fields("SceneId").Value=1
adoRS.Fields("Preview").Value=**** What is expected here? *****
adoRS.Update()
adoRS.Close()
More information about the Python-win32
mailing list