From programmer at paradigm-corp.com Fri May 4 11:29:41 2007 From: programmer at paradigm-corp.com (Programmer) Date: Fri May 4 16:37:03 2007 Subject: [egenix-users] Help with Full-Text Query in SQL Method Message-ID: <611B913B025B1B4494E40781B4F6A61C01E52902@SERVER.paradigm-corp.com> This is more of a Zope problem than a mxODBC problem but I thought I might try bouncing it here. I have a table where TWO columns must be full-text searchable (the reasoning is beyond me!). Additionally, there is also several fixed value qualifiers. So to test the full-text query I came up with: select ResultID, Synopsis from RESULT where contains (Synopsis, '"text"') or contains (Description, '"text"') This query works fine but I run into trouble with Zopifying it. I can't use dtml-sqlvar because it's quoting messes up the way text must be quoted in this type of query. So I end up with this - yes it's ugly. select ResultID, Synopsis from RESULT where contains (Synopsis, '""') or contains (Description, '""') But it works. So now I add the qualifiers and the SQL-Method gets kinda complicated: select ResultID, AcronymID, Synopsis from RESULT contains (Synopsis, '""') contains (Description, '""') Problem here is if I run this with only the full-text variable I get this: select ResultID, AcronymID, Synopsis from RESULT where (contains (Synopsis, '"certs"') and contains (Description, '"certs"') ) The OR gets replaced with AND. Any ideas what I'm missing here? Is there perhaps a less ugly way to do this? Thanks! M. A. Ruberto (Programmer) Every piece of knowledge must have a single, unambiguous, authoritative representation within a system. -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20070504/e0d26b23/attachment.htm From charlie at egenix.com Fri May 4 18:09:48 2007 From: charlie at egenix.com (Charlie Clark) Date: Fri May 4 17:09:55 2007 Subject: [egenix-users] Help with Full-Text Query in SQL Method In-Reply-To: <611B913B025B1B4494E40781B4F6A61C01E52902@SERVER.paradigm-corp.com> References: <611B913B025B1B4494E40781B4F6A61C01E52902@SERVER.paradigm-corp.com> Message-ID: Am 04.05.2007, 16:29 Uhr, schrieb Programmer : > This is more of a Zope problem than a mxODBC problem but I thought I > might try bouncing it here. I have a table where TWO columns must be > full-text searchable (the reasoning is beyond me!). Additionally, there > is also several fixed value qualifiers. > So to test the full-text query I came up with: This is entirely a Zope problem so please take it up on the zope-db list. FWIW I never use the or stuff as I can never figure out what is going to be generated. What SQL do you want generated and what are the variables that you may depend on? If you do run into difficulty using ZSQL then it's probably worth knowing that you can call the mxODBCZopeDA via an ExternalMethod giving yourself complete control over the syntax and passing in variables using the ODBC syntax. I've posted several examples to the zope-db list in the past. Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From mal at egenix.com Thu May 10 14:37:44 2007 From: mal at egenix.com (M.-A. Lemburg) Date: Thu May 10 13:39:50 2007 Subject: [egenix-users] Relaunch of the eGenix.com Website Message-ID: <46430408.3010600@egenix.com> Hello, We are pleased to announce the relaunch of our web-site: http://www.egenix.com/ Over the past few months, we've been working hard on the new eGenix.com web-site. The site now uses Zope and its Content Management Framework (CMF) as basis for delivering content and is driven by a simple and easy to use content management system. We have tried to make the site more accessible and easier to navigate. The aim is to put more and more of our internal support documentation, presentations, howtos and FAQs up online for easy access by our users. Most of the old URLs should continue to work and will now get redirected to the new pages. If you need to access the old versions of our eGenix.com mx Extensions, you can do so by visiting the old overview page at http://www.egenix.com/www2002/python/eGenix-mx-Extensions.html If you find problems with the new site, please let us know. PS: You can read this announcement online on our news page (http://www.egenix.com/company/news/). We've also set up an RSS2 feed for those of you prefer to read things that way. PPS: As you may have noticed, we've not only redone the web-site, but also released new versions of our software. The announcements for these will be sent in separate email. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 10 2007) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From info at egenix.com Thu May 10 18:31:07 2007 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Thu May 10 17:36:41 2007 Subject: [egenix-users] ANN: eGenix mx Base Distribution 3.0.0 (mxDateTime, mxTextTools, etc.) Message-ID: <46433ABB.7030908@egenix.com> ________________________________________________________________________ ANNOUNCING eGenix.com mx Base Extension Package Version 3.0.0 Open Source Python extensions providing important and useful services for Python programmers. This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.0-GA.html ________________________________________________________________________ ABOUT The eGenix.com mx Base Extensions for Python are a collection of professional quality software tools which enhance Python's usability in many important areas such as fast text searching, date/time processing and high speed data types. The tools have a proven record of being portable across many Unix and Windows platforms. You can write applications which use the tools on Windows and then run them on Unix platforms without change due to the consistent platform independent interfaces. All available packages have proven their stability and usefulness in many mission critical applications and various commercial settings all around the world. * About Python: Python is an object-oriented Open Source programming language which runs on all modern platforms (http://www.python.org/). By integrating ease-of-use, clarity in coding, enterprise application connectivity and rapid application design, Python establishes an ideal programming platform for todays IT challenges. * About eGenix: eGenix is a consulting and software product company focused on providing professional quality services and products to Python users and developers (http://www.egenix.com/). ________________________________________________________________________ NEWS The 3.0 release of the eGenix mx Base Distributions comes with a huge number of enhancements, bug fixes and additions. Some highlights: * All mx Extensions have been ported to Python 2.5. * mxDateTime has support for working with Python's datetime module types, so you can use and combine both if necessary. The parser was enhanced to support even more formats and make it more reliable than ever before. * mxTextTools now fully supports Unicode, so you can parse Unicode data just as fast as you can 8-bit string data. The package also includes a tag table compiler and new jump target support to simplify working with tag tables. * mxURL and mxUID were previously released as part of our mx Experimental distribution. They have now been integrated into the base distribution, providing easy-to-use data types for common tasks in web programming. * We've switched from the old distutils wininst installer to the new MSI installer for the Windows Python 2.5 build. This gives you a lot more options for automatic installs, including unattended installs. See http://www.python.org/download/releases/2.5/msi/ for details. For a more detailed description of changes, please see the respective package documentation on our web-site. As always we are providing pre-compiled versions of the package for Windows, Linux, Mac OS X, FreeBSD and Solaris as well as sources which allow you to install the package on all other supported platforms. ________________________________________________________________________ DOWNLOADS The download archives and instructions for installing the packages can be found on the eGenix mx Base Distribution page: http://www.egenix.com/products/python/mxBase/ ________________________________________________________________________ UPGRADING Please note that the 2.0 series of the eGenix mx Base Distribution does not support Python 2.5 on 64-bit platforms due to the Py_ssize_t changes in the Python C API. You are encouraged to upgrade to the new 3.0 series, if you plan to deploy on 64-bit platforms and use Python 2.5 as basis for your applications. ________________________________________________________________________ LICENSES & COSTS The eGenix mx Base package is distributed under the eGenix.com Public License which is a CNRI Python License style Open Source license. You can use the package in both commercial and non-commercial settings without fee or charge. The package comes with full source code ________________________________________________________________________ SUPPORT Commercial support for these packages is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 10 2007) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From info at egenix.com Thu May 10 18:34:02 2007 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Thu May 10 17:36:46 2007 Subject: [egenix-users] ANN: eGenix mxODBC Distribution 3.0.0 (mxODBC Database Interface) Message-ID: <46433B6A.8030809@egenix.com> ________________________________________________________________________ ANNOUNCING eGenix.com mxODBC Database Interface Version 3.0.0 Our commercially supported Python extension providing ODBC database connectivity to Python applications on Windows and Unix platforms This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-mxODBC-Distribution-3.0-GA.html ________________________________________________________________________ ABOUT The mxODBC Database Interface allows users to easily connect Python applications to just about any database on the market today - on both Windows and Unix platforms in a highly portable and convenient way. This makes mxODBC the ideal basis for writing cross-platform database programs and utilities in Python. mxODBC is included in the eGenix.com mxODBC Distribution for Python, a commercial part of the eGenix.com mx Extension Series, a collection of professional quality software tools which enhance Python's usability in many important areas such as ODBC database connectivity, fast text processing, date/time processing and web site programming. The package has proven its stability and usefulness in many mission critical applications and various commercial settings all around the world. * About Python: Python is an object-oriented Open Source programming language which runs on all modern platforms (http://www.python.org/). By integrating ease-of-use, clarity in coding, enterprise application connectivity and rapid application design, Python establishes an ideal programming platform for todays IT challenges. * About eGenix: eGenix is a consulting and software product company focused on providing professional quality services and products to Python users and developers (http://www.egenix.com/). ________________________________________________________________________ NEWS mxODBC 3.0 has received a large number of enhancements and supports more ODBC drivers than ever. Some highlights: * mxODBC has been ported to Python 2.5. * We've worked a lot on the Unicode support and made it more robust, especially on Unix platforms where the ODBC Unicode support has stabilized over the last few years. You can now issue commands using Unicode and exchange Unicode data with the database in various configurable ways. * We've also added a methods to give you more control of the connections and cursors as well as the .callproc() method for calling stored procedures that mxODBC 2.0 was missing. * Multiple result sets via the .nextset() are also supported, so working with stored procedures should be a lot easier now. * Another highlight is the added support for Python's datetime module types and the option to use strings for date/time processing (e.g. to be able to use timezones in timestamps if that's supported by the database). * Python's decimal module is now supported as well and it's possible to configure mxODBC to return Decimal types for numeric values. * mxODBC 3.0 received full 64-bit support, so that you can run mxODBC (and all other mx Extensions) on e.g. AMD64 platforms. * We've switched from the old distutils wininst installer to the new MSI installer for the Windows Python 2.5 build. This gives you a lot more options for automatic installs, including unattended installs. See http://www.python.org/download/releases/2.5/msi/ for details. Note that in order to avoid confusion, we've decided to rename the eGenix.com mx Commercial Distribution to eGenix.com mxODBC Distribution with this release. The commercial distribution has always only contained the mxODBC package, so this was an obvious step to clarify things for our users. As always we are providing pre-compiled versions of the package for Windows, Linux, Mac OS X, FreeBSD and Solaris as well as sources which allow you to install the package on all other supported platforms. ________________________________________________________________________ DOWNLOADS The download archives and instructions for installing the package can be found at: http://www.egenix.com/products/python/mxODBC/ IMPORTANT: In order to use the eGenix mx Commercial package you will first need to install the eGenix mx Base package which can be downloaded from here: http://www.egenix.com/products/python/mxBase/ ________________________________________________________________________ UPGRADING Please note that mxODBC 2.0 does not support Python 2.5 on 64-bit platforms due to the Py_ssize_t changes in the Python C API. You are encouraged to upgrade to the new mxODBC 3.0 release, if you plan to deploy on 64-bit platforms and use Python 2.5 as basis for your applications. ________________________________________________________________________ LICENSES & COSTS This release brings you all the new features and enhancements in mxODBC that were previously only available in through our mxODBC Zope Database Adapter. Like the Zope product, mxODBC now requires that you install a license in order to use it. You can request 30-day evaluation licenses by writing to sales@egenix.com, stating your name (or the name of the company) and the number of eval licenses that you need. We will then issue you licenses and send them to you by email. Please make sure that you can receive ZIP file attachments on the email you specify in the request, since the license files are send out as ZIP attachements. _______________________________________________________________________ SUPPORT Commercial support for these packages is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 10 2007) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From programmer at paradigm-corp.com Fri May 11 12:47:17 2007 From: programmer at paradigm-corp.com (Programmer) Date: Fri May 11 17:46:38 2007 Subject: [egenix-users] Increase pool? Message-ID: <611B913B025B1B4494E40781B4F6A61C01E52B0B@SERVER.paradigm-corp.com> My application has been put into production use and has been running good for a week now. Today it spit this at me three times: Exception Type Warning Exception Value ('01000', 10054, '[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionWrite (send()).', 6113) Is it trying to tell me I need to increase my connection pool? M. A. Ruberto (Programmer) Every piece of knowledge must have a single, unambiguous, authoritative representation within a system. -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20070511/14ae73c1/attachment.htm From charlie at egenix.com Fri May 11 18:58:03 2007 From: charlie at egenix.com (Charlie Clark) Date: Fri May 11 17:58:14 2007 Subject: [egenix-users] Increase pool? In-Reply-To: <611B913B025B1B4494E40781B4F6A61C01E52B0B@SERVER.paradigm-corp.com> References: <611B913B025B1B4494E40781B4F6A61C01E52B0B@SERVER.paradigm-corp.com> Message-ID: Am 11.05.2007, 17:47 Uhr, schrieb Programmer : > My application has been put into production use and has been running > good for a week now. Today it spit this at me three times: > Exception Type Warning > Exception Value ('01000', 10054, '[Microsoft][ODBC SQL Server > Driver][DBNETLIB]ConnectionWrite (send()).', 6113) > Is it trying to tell me I need to increase my connection pool? I don't think so. This is an MS SQL error message. Best checking the msdn.com site for what it actually means. Are you connected to the server by a network? Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From charlie at egenix.com Sat May 12 02:09:01 2007 From: charlie at egenix.com (Charlie Clark) Date: Sat May 12 01:09:14 2007 Subject: [egenix-users] Increase pool? In-Reply-To: <611B913B025B1B4494E40781B4F6A61C01E52B18@SERVER.paradigm-corp.com> References: <611B913B025B1B4494E40781B4F6A61C01E52B18@SERVER.paradigm-corp.com> Message-ID: Am 11.05.2007, 19:23 Uhr, schrieb Programmer : > Charlie, > I have spent about two hours trying to research it on MSDN and don't > have any definate ideas about the cause from that. It seemed to me that > where other users had posted messages relating to it the problem was > having to do with connection traffic. > Since going into production I have disconnected the local dev DB and now > connect to SQL on the network server. I am using windows performance > monitor to watch my TCP Segments Sent to see if the errors crop up > during periods of high traffic on Zope. There are counters for SQL > Server in here they will only show my local instance. Since 98% of SQL > connections are going to happen when Zope sends pages I figure watching > TCP Segments Sent makes sense. > My other theory is the errors occurred when the network server was real > busy with one of it's services like email. The 3 errors occurred between > 8:28am and 8:38am when most people are logging into their email for the > first time. There's been no other occurrances since. > I doubt this has anything to do with mxODBC. I'll try taking it up to > SQL Server Central and see if anybody there can shed some light. Network problems are very common and there is little or nothing a database driver can do. Once a connection is open, it will stay open unless it is explicitly closed. You might try monitoring the connection and manually closing and reopening via a PythonScript but apart from that you need to hound your network admins and DBA's not to drop connections as a high amount of network traffic is no reason for a persistent connection to be dropped. Good luck! Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From tommi.auvinen at wicom.com Mon May 14 18:01:05 2007 From: tommi.auvinen at wicom.com (Tommi Auvinen) Date: Mon May 14 16:01:52 2007 Subject: [egenix-users] Empty strings and executedirect Message-ID: Environment: Windows client and SQLServer. Python 2.43 and mxODBC 2.0.7. When I do the following insert using execute direct (C = char, VC=varchar etc.) "INSERT INTO Testi (C, VC, NC, NVC) VALUES (?,?,?,?)" using parameters ("", "",""; "") the resulting insert is as follows exec sp_executesql N'INSERT INTO Testi (C, VC, NC, NVC) VALUES (@P1,@P2,@P3,@P4)',N'@P1 char(8000),@P2 char(8000),@P3 char(8000),@P4 char(8000) ... ...and the data for each fields really is 8000 spaces. The same using strings with one space (" ", " "," "; " ") works as expected: exec sp_executesql N'INSERT INTO Testi (C, VC, NC, NVC) VALUES (@P1,@P2,@P3,@P4)',N'@P1 char(1),@P2 char(1),@P3 char(1),@P4 char(1)',' ',' ',' ',' ' So, am I missing something and or is this a bug? R:TAu -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20070514/4df17cdb/attachment.htm From mal at egenix.com Tue May 15 00:40:15 2007 From: mal at egenix.com (M.-A. Lemburg) Date: Mon May 14 23:40:21 2007 Subject: [egenix-users] Empty strings and executedirect In-Reply-To: References: Message-ID: <4648D73F.1050206@egenix.com> On 2007-05-14 16:01, Tommi Auvinen wrote: > Environment: Windows client and SQLServer. Python 2.43 and mxODBC 2.0.7. > > > > When I do the following insert using execute direct (C = char, > VC=varchar etc.) > > "INSERT INTO Testi (C, VC, NC, NVC) VALUES (?,?,?,?)" > > > > using parameters ("", "",""; "") > > > > the resulting insert is as follows > > exec sp_executesql N'INSERT INTO Testi (C, VC, NC, NVC) VALUES > (@P1,@P2,@P3,@P4)',N'@P1 char(8000),@P2 char(8000),@P3 char(8000),@P4 > char(8000) ... > > ...and the data for each fields really is 8000 spaces. > > > > The same using strings with one space (" ", " "," "; " ") works as > expected: > > exec sp_executesql N'INSERT INTO Testi (C, VC, NC, NVC) VALUES > (@P1,@P2,@P3,@P4)',N'@P1 char(1),@P2 char(1),@P3 char(1),@P4 char(1)',' > ',' ',' ',' ' > > > > So, am I missing something and or is this a bug? This looks a lot like a bug in the ODBC driver. It seem to convert the empty data to a char(8000) column (which is padded with spaces in SQL Server and many other database backends). OTOH, you could also view it as bug in the way the one character data is handled. Depends on the table schema. If this is indeed a char(8000) column, then the one character data should also be padded to 8000 characters. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 14 2007) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From tommi.auvinen at wicom.com Wed May 16 16:38:18 2007 From: tommi.auvinen at wicom.com (Tommi Auvinen) Date: Wed May 16 14:38:28 2007 Subject: [egenix-users] Empty strings and executedirect In-Reply-To: <4648D73F.1050206@egenix.com> References: <4648D73F.1050206@egenix.com> Message-ID: I dug a bit deeper and enabled the ODBC driver trace, and noticed that all three data lengths are 0 when handling empty string. I tried changing these values (so that buf len is at least 1) so that terminating NULL goes to the driver as well, but it did no help. But by doing the following (just to test, not complete or even right solution...) just before SQLBindParameters helped: if (var->ctype==SQL_C_CHAR && var->sqllen==0) { var->sqltype=SQL_VARCHAR; } So it seems that CHAR(0) cannot be interpreted (as one would expect) by ODBC driver. In fact, the column description is still 8000 characters (in schema the column lengths are only some tens of chars), but now the actual data is OK, and SQL Server can do the varchar-->char conversions: exec sp_executesql N'INSERT INTO Testi (C, VC, NC, NVC, I) VALUES (@P1,@P2,@P3,@P4,@P5)',N'@P1 varchar(8000),@P2 varchar(8000),@P3 varchar(8000),@P4 varchar(8000),@P5 int','','','','',0 R:TAu PS: The table def: /****** Object: Table [dbo].[Testi] Script Date: 05/16/2007 15:34:59 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Testi]( [C] [char](10) NULL, [NC] [nchar](10) NULL, [VC] [varchar](50) NULL, [NVC] [nvarchar](50) NULL, [TimeStamp] [timestamp] NULL, [I] [int] NULL ) ON [PRIMARY] GO SET ANSI_PADDING OFF -----Original Message----- From: M.-A. Lemburg [mailto:mal@egenix.com] Sent: 15. toukokuuta 2007 0:40 To: Tommi Auvinen Cc: egenix-users@egenix.com Subject: Re: [egenix-users] Empty strings and executedirect On 2007-05-14 16:01, Tommi Auvinen wrote: > Environment: Windows client and SQLServer. Python 2.43 and mxODBC 2.0.7. > > > > When I do the following insert using execute direct (C = char, > VC=varchar etc.) > > "INSERT INTO Testi (C, VC, NC, NVC) VALUES (?,?,?,?)" > > > > using parameters ("", "",""; "") > > > > the resulting insert is as follows > > exec sp_executesql N'INSERT INTO Testi (C, VC, NC, NVC) VALUES > (@P1,@P2,@P3,@P4)',N'@P1 char(8000),@P2 char(8000),@P3 char(8000),@P4 > char(8000) ... > > ...and the data for each fields really is 8000 spaces. > > > > The same using strings with one space (" ", " "," "; " ") works as > expected: > > exec sp_executesql N'INSERT INTO Testi (C, VC, NC, NVC) VALUES > (@P1,@P2,@P3,@P4)',N'@P1 char(1),@P2 char(1),@P3 char(1),@P4 char(1)',' > ',' ',' ',' ' > > > > So, am I missing something and or is this a bug? This looks a lot like a bug in the ODBC driver. It seem to convert the empty data to a char(8000) column (which is padded with spaces in SQL Server and many other database backends). OTOH, you could also view it as bug in the way the one character data is handled. Depends on the table schema. If this is indeed a char(8000) column, then the one character data should also be padded to 8000 characters. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 14 2007) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From rafaelpinilla at free.fr Thu May 17 14:05:02 2007 From: rafaelpinilla at free.fr (Rafael Pinilla) Date: Thu May 17 13:05:15 2007 Subject: [egenix-users] Hi all, bug or feature? Message-ID: <464C36DE.4070204@free.fr> hi all. i'm in the process to make SQL requests in an automatic way. Right now, the data are in a Sybase SQL anywhere 7 database providing native ODBC driver as System DSN on Win32 platform. The base is quite complex, with more than 20 tables and more than 800.000 records in one table, 5 years old, with integrity reference checking from beginning. I installed mxODBC, with test license, and I tried to reach my data. After I figured out how to firt create an instance of the connexion, then an instance of the cursor, I tried hard coded SQL statement. I gracefully had a sequence of tuples result. As I wanted to count some results, i tried cursor.rowcount() Afortunately the results were very different from direct SQL based request (like isql statements). A deeper look showed me that the sequence of tuples were right until the last row, and then, a variable amount of null tuples were added. So, cursor.rowcount return the good number of rows, but there are more empty (null) rows than expected. I really can't figure why. I found a workaound using i=1 courant = list(cur.fetchone()) while courant[1] <> () : print i courant = cur.fetchone() print courant i = i+1 In these lines, I convert the tuple in a list to let python make a test on the first (second, yes I figure) item. This is a right cursor.rowcount workaround for suspicious dummies. So, this bug dont stop me. Perhaps is it a bug, perhaps an unknown feature. I can give more information, perhaps a shelve of the resulting tuple. Ask me if you want. Perhaps the cursor.rowcount method should make a test to stop inserting null tuples at the end of the sequence of (good) tuples. Thanks for your reaction. Rafael From mal at egenix.com Thu May 17 14:26:46 2007 From: mal at egenix.com (M.-A. Lemburg) Date: Thu May 17 13:26:52 2007 Subject: [egenix-users] Hi all, bug or feature? In-Reply-To: <464C36DE.4070204@free.fr> References: <464C36DE.4070204@free.fr> Message-ID: <464C3BF6.4020107@egenix.com> On 2007-05-17 13:05, Rafael Pinilla wrote: > hi all. > > i'm in the process to make SQL requests in an automatic way. Right now, > the data are in a Sybase SQL anywhere 7 database providing native ODBC > driver as System DSN on Win32 platform. > > The base is quite complex, with more than 20 tables and more than > 800.000 records in one table, 5 years old, with integrity reference > checking from beginning. > > I installed mxODBC, with test license, and I tried to reach my data. > > After I figured out how to firt create an instance of the connexion, > then an instance of the cursor, I tried hard coded SQL statement. > > I gracefully had a sequence of tuples result. As I wanted to count some > results, i tried cursor.rowcount() Afortunately the results were very > different from direct SQL based request (like isql statements). > > A deeper look showed me that the sequence of tuples were right until the > last row, and then, a variable amount of null tuples were added. You should be getting None returns from cur.fetchone() if you fetch beyond the end of the result set. > So, cursor.rowcount return the good number of rows, but there are more > empty (null) rows than expected. I really can't figure why. > > I found a workaound using > i=1 > courant = list(cur.fetchone()) > while courant[1] <> () : I'm not sure what the above line is supposed to do. courant[1] should be a value from a result set row and that can never be a tuple. > print i > courant = cur.fetchone() > print courant > i = i+1 > > In these lines, I convert the tuple in a list to let python make a test > on the first (second, yes I figure) item. This is a right > cursor.rowcount workaround for suspicious dummies. > > So, this bug dont stop me. Perhaps is it a bug, perhaps an unknown > feature. I can give more information, perhaps a shelve of the resulting > tuple. Ask me if you want. Perhaps the cursor.rowcount method should > make a test to stop inserting null tuples at the end of the sequence of > (good) tuples. Please try to use cur.fetchall() which will return the complete result set and see whether that makes a difference. Note that some ODBC drivers don't behave well when you try to fetch beyond the end of the result set. mxODBC has no means of checking this, since it relies on the ODBC driver to return a proper value for "no more data available". Also note that .rowcount doesn't always work with ODBC drivers, or depends on settings in the database or the driver. The reason is that calculating the exact number of rows in a result set is rather expensive and often drivers and/or databases fetch the results in an on-demand way. You can use the mx/ODBC/Misc/test.pyc script to check whether a database driver has problems with all of the above or not. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 17 2007) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From novin01 at gmail.com Fri May 25 15:12:31 2007 From: novin01 at gmail.com (Novin) Date: Fri May 25 15:12:37 2007 Subject: [egenix-users] Unexpected Behaviour of DateTimeFromTicks Message-ID: I'm trying to round a date to the nearest hour. To do so I converted it to a float using ticks(), rounded it then converted it back to a DateTime object using DateTimeFromTicks. Unfortunately this didn't work as I expected on clock change days - see below: Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] Type "copyright", "credits" or "license" for more information. IPython 0.8.1.rc3 -- An enhanced Interactive Python. ? -> Introduction to IPython's features. %magic -> Information about IPython's 'magic' % functions. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. Welcome to pylab, a matplotlib-based Python environment. For more information, type 'help(pylab)'. In [1]: import mx.DateTime In [2]: mx.DateTime.__version__ Out[2]: '3.0.0' In [3]: comdate = 35155.04167 In [4]: mxdate1 = mx.DateTime.DateTimeFromCOMDate(comdate) In [5]: print mxdate1 1996-03-31 01:00:00.28 In [6]: mxdate2 = mx.DateTime.DateTimeFromTicks(mxdate1.ticks()) In [7]: mxdate1 == mxdate2 Out[7]: False In [8]: print mxdate2 1996-03-31 00:00:00.28 Is this the expected behaviour? It seems a little un-intuitive to me! NB: using .absvalues() and DateTimeFromAbsDateTime works as expected. Rgds, Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20070525/1be778f6/attachment.htm From mal at egenix.com Fri May 25 16:33:08 2007 From: mal at egenix.com (M.-A. Lemburg) Date: Fri May 25 15:33:13 2007 Subject: [egenix-users] Unexpected Behaviour of DateTimeFromTicks In-Reply-To: References: Message-ID: <4656E594.4010409@egenix.com> On 2007-05-25 15:12, Novin wrote: > I'm trying to round a date to the nearest hour. To do so I converted it to > a float using ticks(), rounded it then converted it back to a DateTime > object > using DateTimeFromTicks. > > Unfortunately this didn't work as I expected on clock change days - see > below: > > Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] > Type "copyright", "credits" or "license" for more information. > > IPython 0.8.1.rc3 -- An enhanced Interactive Python. > ? -> Introduction to IPython's features. > %magic -> Information about IPython's 'magic' % functions. > help -> Python's own help system. > object? -> Details about 'object'. ?object also works, ?? prints more. > > Welcome to pylab, a matplotlib-based Python environment. > For more information, type 'help(pylab)'. > > In [1]: import mx.DateTime > > In [2]: mx.DateTime.__version__ > Out[2]: '3.0.0' > > In [3]: comdate = 35155.04167 > > In [4]: mxdate1 = mx.DateTime.DateTimeFromCOMDate(comdate) > > In [5]: print mxdate1 > 1996-03-31 01:00:00.28 > > In [6]: mxdate2 = mx.DateTime.DateTimeFromTicks(mxdate1.ticks()) > > In [7]: mxdate1 == mxdate2 > Out[7]: False > > In [8]: print mxdate2 > 1996-03-31 00:00:00.28 > > > Is this the expected behaviour? It seems a little un-intuitive to me! > > NB: using .absvalues() and DateTimeFromAbsDateTime works as expected. Hmm, on Linux I get: >>> import mx.DateTime >>> comdate = 35155.04167 >>> mxdate1 = mx.DateTime.DateTimeFromCOMDate(comdate) >>> mxdate2 = mx.DateTime.DateTimeFromTicks(mxdate1.ticks()) >>> print mxdate1, mxdate2 1996-03-31 01:00:00.28 1996-03-31 01:00:00.28 They still don't compare equal due to float rounding issues: >>> mxdate1 == mxdate2 False Note that ticks always work with local time, so I suppose this is due to problems with DST support in the MS C lib for that year. Also tried a few other dates: >>> comdate = 35255.04167 >>> mxdate1 = mx.DateTime.DateTimeFromCOMDate(comdate) >>> mxdate2 = mx.DateTime.DateTimeFromTicks(mxdate1.ticks()) >>> print mxdate1, mxdate2 1996-07-09 01:00:00.28 1996-07-09 01:00:00.28 >>> comdate = 35105.04167 >>> mxdate1 = mx.DateTime.DateTimeFromCOMDate(comdate) >>> mxdate2 = mx.DateTime.DateTimeFromTicks(mxdate1.ticks()) >>> print mxdate1, mxdate2 1996-02-10 01:00:00.28 1996-02-10 01:00:00.28 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 25 2007) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From info at egenix.com Tue May 29 18:33:08 2007 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Tue May 29 17:34:55 2007 Subject: [egenix-users] ANN: eGenix mxODBC 3.0 Developer Licenses (mxODBC Database Interface) Message-ID: <465C47B4.6050902@egenix.com> ________________________________________________________________________ eGenix.com mxODBC 3.0 Developer Licenses Available ________________________________________________________________________ eGenix is pleased to announce the immediate availability of developer licenses for our Python ODBC database interface, the eGenix mxODBC Distribution 3.0 for Python. This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/mxODBC-3.0-Developer-License-Announcement.html ________________________________________________________________________ INTRODUCTION The eGenix mxODBC Distribution is an add-on distribution for our eGenix mx Base Distribution. It comes with mxODBC, our universal ODBC database interface for Python. ________________________________________________________________________ DEVELOPER LICENSES FOR mxODBC 3.0 eGenix is now shipping developer licenses for mxODBC which allow the integration and redistribution of mxODBC into your products. * Make use of the power and flexibility of this cross-platform, robust and stable interface and connect to most available databases with less hassles, fewer configuration problems and great performance. * Enjoy the same database interface API on all supported platforms: Windows, Linux, Mac OS X, FreeBSD and Solaris. * This is true write-once, deploy anywhere ! ________________________________________________________________________ HOW DOES IT WORK ? The setup works just like for a regular stand-alone installation of mxODBC. eGenix will send you the required license files after purchase and all you have to do, is install them in the product folder. You can then work on your product and ship the license files together with the product, so that your customers can use the product integrated mxODBC just like you do on your development machines. Once licensed, you don't have to pay eGenix royalties or fees for distributing mxODBC together with your products. ________________________________________________________________________ WHICH RESTRICTIONS APPLY ? Restrictions are very modest: * you must get a proper license for all developer machines and developers working on the product * the mxODBC version included in the product must be tied to your product, ie. it should not be usable outside your product * you are not permitted to use mxODBC in a product that would introduce competition for eGenix products. The full legal details are available in the eGenix.com Commercial License Agreement 1.2.0. Please see the product page for details: http://www.egenix.com/products/python/mxODBC/#Licensing ________________________________________________________________________ TRY BEFORE YOU BUY You can request 30-day evaluation licenses by writing to sales@egenix.com, stating your name (or the name of the company) and the number of eval licenses that you need. We will then issue you licenses and send them to you by email. Please make sure that you can receive ZIP file attachments on the email you specify in the request, since the license files are send out as ZIP attachements. ________________________________________________________________________ PRICING mxODBC 3.0 Developer CPU Licenses can be purchased in our eGenix Online Shop at http://www.egenix.com/shop/. Please see the mxODBC distribution page for details on buying licenses or contact sales@egenix.com. ________________________________________________________________________ DOWNLOADS The download archives and instructions for installing the package can be found at: http://www.egenix.com/products/python/mxODBC/ IMPORTANT: In order to use the eGenix mx Commercial package you will first need to install the eGenix mx Base package which can be downloaded from here: http://www.egenix.com/products/python/mxBase/ _______________________________________________________________________ SUPPORT Commercial support for these packages is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 29 2007) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611