David:<br> You do not mention the version of adodbapi you are using. <br>>>>import adodbapi<br>>>>print adodbapi.version<br><br>2.4.2.2 is current. Some older versions have known problems with large binary fields -- which is just exactly what you are using.<br>
Please try again with a current version if you have not done that. If that does not do the trick, then there is yet another bug to chase...<br>download from <a href="http://sourceforge.net/projects/adodbapi">http://sourceforge.net/projects/adodbapi </a>or get the latest pywin32. <br>
<br>--<br>Vernon Cole<br><br><div class="gmail_quote">On Thu, May 17, 2012 at 11:01 AM, David L. Page <span dir="ltr"><<a href="mailto:page3d@gmail.com" target="_blank">page3d@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>Hi,<br><div class="gmail_quote"><div><div><br></div><div>I have an .sdf file (SQL CE 3.5) that someone has given me. I need to extract some data from the file (and will need to extract similar data from similar files in the future). I'm trying to write a python script to do it.</div>
<div><br></div><div>The DB file has a table (Profiles) with three items (DataID (int), Data (varbinary[8000], CreationDate(datetime)). I am having a problem accessing the varbinary data in Data. Here's a code snippet that works for the CreationDate.</div>
<div><br></div><div>==== Begin Code (test.py) ====</div><div><div>import adodbapi</div><div><br></div><div>file = "D:\\Not_Synced\\Code\\GetProfile\\20120516_111500\\ProfileDB.1.1.sdf"</div><div>
connstr = 'Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; Data Source=%s;' % file</div><div>conn = adodbapi.connect(connstr)</div><div>cur = conn.cursor()</div><div>sql = "select CreationDate from Profiles where DataID = 2"</div>
<div>cur.execute(sql)</div><div>result = cur.fetchall()</div><div>for item in result:</div><div><span style="white-space:pre-wrap">        </span>print item</div><div><span style="white-space:pre-wrap">        </span></div>
<div>cur.close()</div><div>conn.close()</div><div>==== End Code ==== </div><div><br></div><div>==== Begin Output ====</div><div><div><br></div><div>D:\Not_Synced\Code\GetProfile\20120516_111500>python test.py</div>
<div>adodbapi v2.4.2.2 attempting: "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; Data S</div><div>ource=D:\Not_Synced\Code\GetProfile\20120516_111500\ProfilesDB.1.1.sdf;"</div><div>adodbapi New connection at 2C034F0</div>
<div>adodbapi New cursor at 2C03B50 on conn 2C034F0</div><div>Executing command="select CreationDate from Profiles where DataID = 2"</div><div>('2012-01-18 10:54:19.843000',)</div><div>adodbapi Closed connection at 2C034F0</div>
<div><br></div></div><div>==== End Output ====</div><div><br></div><div>That code snippet accesses the date just fine.</div><div><br></div><div>However, when I try to access the Data by changing the select command:</div>
<div><br></div><div>sql = "select CreationDate from Profiles where DataID = 2"</div><div><br></div><div>I get the following error.</div><div><br></div><div>==== Begin Output2 ====</div>
<div><div><br></div><div>D:\Not_Synced\Code\GetProfile\20120516_111500>python test2.py</div><div>adodbapi v2.4.2.2 attempting: "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; Data S</div><div>ource=D:\Not_Synced\Code\GetProfile\20120516_111500\ProfilesDB.1.1.sdf"</div>
<div>adodbapi New connection at 2C834F0</div><div>adodbapi New cursor at 2C83B50 on conn 2C834F0</div><div>Executing command="select Data from Profiles where DataID = 2"</div><div>Traceback (most recent call last):</div>
<div> File "test.py", line 9, in <module></div><div> cur.execute(sql)</div><div> File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 1008, in execu</div><div>te</div><div> self._execute_command()</div>
<div> File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 893, in _execu</div><div>te_command</div><div> self._raiseCursorError(klass, _message)</div><div> File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 758, in _raise</div>
<div>CursorError</div><div> eh(self.connection,self,errorclass,errorvalue)</div><div> File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 107, in standa</div><div>rdErrorHandler</div><div> raise errorclass(errorvalue)</div>
<div>adodbapi.adodbapi.DatabaseError: <a href="tel:%28-2147352567" value="+12147352567" style="color:rgb(17,85,204)" target="_blank">(-2147352567</a>, 'Exception occurred.', (0, u'Micr</div><div>osoft SQL Server Compact OLE DB Provider', u'Multiple-step OLE DB operation gene</div>
<div>rated errors. Check each OLE DB status value, if available. No work was done.',</div><div>None, 0, -<a href="tel:2147217887" value="+12147217887" style="color:rgb(17,85,204)" target="_blank">2147217887</a>), None)</div>
<div>Command:</div><div>select Data from Profiles where DataID = 2</div><div>Parameters:</div><div>[]</div><div>adodbapi Closed connection at 2C834F0</div><div><br></div></div><div>==== End Output2 ====</div><div>
<br></div><div>Any help you could provide would be greatly appreciated. Thanks.</div><br></div></div><div>--Dave</div><div><br></div><div>PS I'm using Win7 x64 with a Python 2.7 (32 bit) installation.</div><span class="HOEnZb"><font color="#888888"><span><font color="#888888">
<div><br></div><div><br></div></font></span></font></span></div><span class="HOEnZb"><font color="#888888"><br clear="all"><div><br></div>-- <br>David L. Page<div><div><a href="mailto:davidpage@ieee.org" target="_blank">davidpage@ieee.org</a></div>
</div><br>
</font></span><br>_______________________________________________<br>
python-win32 mailing list<br>
<a href="mailto:python-win32@python.org">python-win32@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-win32" target="_blank">http://mail.python.org/mailman/listinfo/python-win32</a><br>
<br></blockquote></div><br>