[python-win32] Fwd: Trouble with SQL CE 3.5 DB File
Hi, 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. 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. Begin Code (test.py) import adodbapi file = "D:\\Not_Synced\\Code\\GetProfile\\20120516_111500\\ProfileDB.1.1.sdf" connstr = 'Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; Data Source=%s;' % file conn = adodbapi.connect(connstr) cur = conn.cursor() sql = "select CreationDate from Profiles where DataID = 2" cur.execute(sql) result = cur.fetchall() for item in result: print item cur.close() conn.close() End Code Begin Output D:\Not_Synced\Code\GetProfile\20120516_111500>python test.py adodbapi v2.4.2.2 attempting: "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; Data S ource=D:\Not_Synced\Code\GetProfile\20120516_111500\ProfilesDB.1.1.sdf;" adodbapi New connection at 2C034F0 adodbapi New cursor at 2C03B50 on conn 2C034F0 Executing command="select CreationDate from Profiles where DataID = 2" ('2012-01-18 10:54:19.843000',) adodbapi Closed connection at 2C034F0 End Output That code snippet accesses the date just fine. However, when I try to access the Data by changing the select command: sql = "select CreationDate from Profiles where DataID = 2" I get the following error. Begin Output2 D:\Not_Synced\Code\GetProfile\20120516_111500>python test2.py adodbapi v2.4.2.2 attempting: "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; Data S ource=D:\Not_Synced\Code\GetProfile\20120516_111500\ProfilesDB.1.1.sdf" adodbapi New connection at 2C834F0 adodbapi New cursor at 2C83B50 on conn 2C834F0 Executing command="select Data from Profiles where DataID = 2" Traceback (most recent call last): File "test.py", line 9, in cur.execute(sql) File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 1008, in execu te self._execute_command() File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 893, in _execu te_command self._raiseCursorError(klass, _message) File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 758, in _raise CursorError eh(self.connection,self,errorclass,errorvalue) File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 107, in standa rdErrorHandler raise errorclass(errorvalue) adodbapi.adodbapi.DatabaseError: (-2147352567, 'Exception occurred.', (0, u'Micr osoft SQL Server Compact OLE DB Provider', u'Multiple-step OLE DB operation gene rated errors. Check each OLE DB status value, if available. No work was done.', None, 0, -2147217887), None) Command: select Data from Profiles where DataID = 2 Parameters: [] adodbapi Closed connection at 2C834F0 End Output2 Any help you could provide would be greatly appreciated. Thanks. --Dave PS I'm using Win7 x64 with a Python 2.7 (32 bit) installation. -- David L. Page davidp...@ieee.org ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Fwd: Trouble with SQL CE 3.5 DB File
David: You do not mention the version of adodbapi you are using. >>>import adodbapi >>>print adodbapi.version 2.4.2.2 is current. Some older versions have known problems with large binary fields -- which is just exactly what you are using. 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... download from http://sourceforge.net/projects/adodbapi or get the latest pywin32. -- Vernon Cole On Thu, May 17, 2012 at 11:01 AM, David L. Page wrote: > > Hi, > > 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. > > 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. > > Begin Code (test.py) > import adodbapi > > file = > "D:\\Not_Synced\\Code\\GetProfile\\20120516_111500\\ProfileDB.1.1.sdf" > connstr = 'Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; Data Source=%s;' % > file > conn = adodbapi.connect(connstr) > cur = conn.cursor() > sql = "select CreationDate from Profiles where DataID = 2" > cur.execute(sql) > result = cur.fetchall() > for item in result: > print item > cur.close() > conn.close() > End Code > > Begin Output > > D:\Not_Synced\Code\GetProfile\20120516_111500>python test.py > adodbapi v2.4.2.2 attempting: "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; > Data S > ource=D:\Not_Synced\Code\GetProfile\20120516_111500\ProfilesDB.1.1.sdf;" > adodbapi New connection at 2C034F0 > adodbapi New cursor at 2C03B50 on conn 2C034F0 > Executing command="select CreationDate from Profiles where DataID = 2" > ('2012-01-18 10:54:19.843000',) > adodbapi Closed connection at 2C034F0 > > End Output > > That code snippet accesses the date just fine. > > However, when I try to access the Data by changing the select command: > > sql = "select CreationDate from Profiles where DataID = 2" > > I get the following error. > > Begin Output2 > > D:\Not_Synced\Code\GetProfile\20120516_111500>python test2.py > adodbapi v2.4.2.2 attempting: "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; > Data S > ource=D:\Not_Synced\Code\GetProfile\20120516_111500\ProfilesDB.1.1.sdf" > adodbapi New connection at 2C834F0 > adodbapi New cursor at 2C83B50 on conn 2C834F0 > Executing command="select Data from Profiles where DataID = 2" > Traceback (most recent call last): > File "test.py", line 9, in > cur.execute(sql) > File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 1008, in > execu > te > self._execute_command() > File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 893, in > _execu > te_command > self._raiseCursorError(klass, _message) > File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 758, in > _raise > CursorError > eh(self.connection,self,errorclass,errorvalue) > File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 107, in > standa > rdErrorHandler > raise errorclass(errorvalue) > adodbapi.adodbapi.DatabaseError: (-2147352567, 'Exception occurred.', (0, > u'Micr > osoft SQL Server Compact OLE DB Provider', u'Multiple-step OLE DB > operation gene > rated errors. Check each OLE DB status value, if available. No work was > done.', > None, 0, -2147217887), None) > Command: > select Data from Profiles where DataID = 2 > Parameters: > [] > adodbapi Closed connection at 2C834F0 > > End Output2 > > Any help you could provide would be greatly appreciated. Thanks. > > --Dave > > PS I'm using Win7 x64 with a Python 2.7 (32 bit) installation. > > > > > -- > David L. Page > davidp...@ieee.org > > > ___ > python-win32 mailing list > python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > > ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Fwd: Trouble with SQL CE 3.5 DB File
My error! Reading again, I see that your version is up to date. If the data is not private, could you send a zipped copy of your data file to me directly (not to the list)? -- Vernon On Thu, May 17, 2012 at 12:59 PM, Vernon Cole wrote: > David: >You do not mention the version of adodbapi you are using. > >>>import adodbapi > >>>print adodbapi.version > > 2.4.2.2 is current. Some older versions have known problems with large > binary fields -- which is just exactly what you are using. > 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... > download from http://sourceforge.net/projects/adodbapi or get the latest > pywin32. > > -- > Vernon Cole > > On Thu, May 17, 2012 at 11:01 AM, David L. Page wrote: > >> >> Hi, >> >> 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. >> >> 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. >> >> Begin Code (test.py) >> import adodbapi >> >> file = >> "D:\\Not_Synced\\Code\\GetProfile\\20120516_111500\\ProfileDB.1.1.sdf" >> connstr = 'Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; Data Source=%s;' % >> file >> conn = adodbapi.connect(connstr) >> cur = conn.cursor() >> sql = "select CreationDate from Profiles where DataID = 2" >> cur.execute(sql) >> result = cur.fetchall() >> for item in result: >> print item >> cur.close() >> conn.close() >> End Code >> >> Begin Output >> >> D:\Not_Synced\Code\GetProfile\20120516_111500>python test.py >> adodbapi v2.4.2.2 attempting: "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; >> Data S >> ource=D:\Not_Synced\Code\GetProfile\20120516_111500\ProfilesDB.1.1.sdf;" >> adodbapi New connection at 2C034F0 >> adodbapi New cursor at 2C03B50 on conn 2C034F0 >> Executing command="select CreationDate from Profiles where DataID = 2" >> ('2012-01-18 10:54:19.843000',) >> adodbapi Closed connection at 2C034F0 >> >> End Output >> >> That code snippet accesses the date just fine. >> >> However, when I try to access the Data by changing the select command: >> >> sql = "select CreationDate from Profiles where DataID = 2" >> >> I get the following error. >> >> Begin Output2 >> >> D:\Not_Synced\Code\GetProfile\20120516_111500>python test2.py >> adodbapi v2.4.2.2 attempting: "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; >> Data S >> ource=D:\Not_Synced\Code\GetProfile\20120516_111500\ProfilesDB.1.1.sdf" >> adodbapi New connection at 2C834F0 >> adodbapi New cursor at 2C83B50 on conn 2C834F0 >> Executing command="select Data from Profiles where DataID = 2" >> Traceback (most recent call last): >> File "test.py", line 9, in >> cur.execute(sql) >> File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 1008, >> in execu >> te >> self._execute_command() >> File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 893, in >> _execu >> te_command >> self._raiseCursorError(klass, _message) >> File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 758, in >> _raise >> CursorError >> eh(self.connection,self,errorclass,errorvalue) >> File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 107, in >> standa >> rdErrorHandler >> raise errorclass(errorvalue) >> adodbapi.adodbapi.DatabaseError: (-2147352567, 'Exception occurred.', >> (0, u'Micr >> osoft SQL Server Compact OLE DB Provider', u'Multiple-step OLE DB >> operation gene >> rated errors. Check each OLE DB status value, if available. No work was >> done.', >> None, 0, -2147217887), None) >> Command: >> select Data from Profiles where DataID = 2 >> Parameters: >> [] >> adodbapi Closed connection at 2C834F0 >> >> End Output2 >> >> Any help you could provide would be greatly appreciated. Thanks. >> >> --Dave >> >> PS I'm using Win7 x64 with a Python 2.7 (32 bit) installation. >> >> >> >> >> -- >> David L. Page >> davidp...@ieee.org >> >> >> ___ >> python-win32 mailing list >> python-win32@python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> >> > ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Fwd: Trouble with SQL CE 3.5 DB File
Update: I have put together some C# code and I'm able to see the varbinary Data using the MS Visual C# System.Data.SqlServerCe calls. (I am by no means a C# or SQLCE expert. I just thought I'd try another avenue.) I can supply the C# code if desired, but here's the SQL select call that retrieves what I need: using (SqlCeCommand com = new SqlCeCommand("SELECT Data FROM Profiles WHERE DataID=2", con)) Does the mean there's a problem in adodbapi for varbinary(max) data? --Dave -- David L. Page davidp...@ieee.org ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Adding a notification icon from a service
Hi, I have two smallish python modules, one which runs a service, and the other which puts a notification icon with a trivial menu on the windows panel (these modules are quite similar to existing examples in pywin32). Both of these modules work fine by themselves. However when I try to create the notification module from the service, I get troubles. I'm starting the service using win32serviceutil.HandleCommandLine, and it works fine in debug mode (as long as I'm running as Administrator), but when I try to start it, the notification code fails and it won't add the icon; and when I try to stop it, it wont' stop and just hangs. The main problem that I can identify right now is that my calls to win32gui.Shell_NotifyIcon fails. It raises a pywintypes.error(0, 'Shell_NotifyIcon', 'No error message is available'). Does anybody know what this means, or have any idea how to figure out what it means? ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Adding a notification icon from a service
On 18/05/2012 9:00 AM, Alan Trick wrote: Hi, I have two smallish python modules, one which runs a service, and the other which puts a notification icon with a trivial menu on the windows panel (these modules are quite similar to existing examples in pywin32). Both of these modules work fine by themselves. However when I try to create the notification module from the service, I get troubles. I'm starting the service using win32serviceutil.HandleCommandLine, and it works fine in debug mode (as long as I'm running as Administrator), but when I try to start it, the notification code fails and it won't add the icon; and when I try to stop it, it wont' stop and just hangs. The main problem that I can identify right now is that my calls to win32gui.Shell_NotifyIcon fails. It raises a pywintypes.error(0, 'Shell_NotifyIcon', 'No error message is available'). Does anybody know what this means, or have any idea how to figure out what it means? Services don't have access to the desktop which is there the notification bar lives. The usual way to implement this is with 2 processes - one for the service and one for the taskbar, and to implement some kind of RPC between them, such as a named pipe - one of the service samples uses a named pipe so that should get you started. HTH, Mark ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32