I believe this bug is also related to the other problem I just reported.
OS = Windows XP SP2
DB = Microsoft Access XP
PROBLEM:
When you use + (or &) to concatenation columns together and the columns are
of type text and the combined length exceed 255 this causes pyodbc to fail
and python to crash.
Basically
select c2 + ' ' + c3 from test_concat where c1 = 1
will cause the problem if c2 and c3 are text columns and their combined
length is 255.
I also encountered this problem years ago with mxODBC and I believe the
problem may actually be an underlying bug in odbc.
When I contacted Marc-André Lemburg,the author of mxODBC he patched it to
fix the problem and I believe the workaround was to allocate a larger
buffer.
If the columns that are concatenated are memo columns I also believe the
problem occurs.
# pyodbc.Error: ('HY090', '[HY090] [Microsoft][ODBC Driver Manager]
Invalid string
# or buffer length (0)')
To recreate the problem create an Access db named test and create a DSN
named test.
Run the createtable.py script to create the table and then run the broke.py
to demonstrate the problem.
The broke.py script has 4 select statements but only one is executed.
Change line number 34 to specify which one you want to test.
#
# createtable.py script
#
import pyodbc
dbs = pyodbc.connect( 'dsn=test')
c = dbs.cursor()
try:
sql = 'drop table test_concat'
c.execute(sql)
dbs.commit()
except:
# ignore drop table failure
pass
sql = 'create table test_concat (c1 int not null, c2 text not null, c3 text
not null)'
c.execute(sql)
dbs.commit()
sql = 'insert into test_concat values(1, ?, ?)'
c2_value = '1' * 251
c2_value = '%sJOE1' % (c2_value)
c3_value = '1' * 251
c3_value = '%sJOE2' % (c3_value)
c.execute(sql, (c2_value, c3_value))
dbs.commit()
c.close()
dbs.close()
#
# broke.py script
#
import pyodbc
dbs = pyodbc.connect( 'dsn=test')
c = dbs.cursor()
sql1 = "select c2 from test_concat where c1 = 1"
sql2 = "select c2, c3 from test_concat where c1 = 1"
sql3 = "select c2 + ' ' + c3 from test_concat where c1 = 1"
sql4 = "select c2 + ' ' + c3 as a from test_concat where c1 = 1"
#
# 1: Works fine
#
# 2: Works fine
#
# 3: Errors and python crashes
#
# Traceback (most recent call last):
# File "H:\1-pyodbc-bug\concat-bug\broke.py", line 36, in ?
# row = c.fetchone()
# pyodbc.Error: ('HY090', '[HY090] [Microsoft][ODBC Driver Manager]
Invalid string
# or buffer length (0)')
#
# 4: Errors and python crashes
#
# Traceback (most recent call last):
# File "H:\1-pyodbc-bug\concat-bug\broke.py", line 36, in ?
# row = c.fetchone()
# pyodbc.Error: ('HY090', '[HY090] [Microsoft][ODBC Driver Manager]
Invalid string
# or buffer length (0)')
#
c.execute(sql4)
row = c.fetchone()
print row[0]
if len(row) 1: print row[1]
c.close()
dbs.close() 2 5328
En Fri, 18 May 2007 20:48:49 -0300, Joe Salmeri <Jo********@hot mail.com>
escribió:
I believe this bug is also related to the other problem I just reported.
I think you'll get best results reporting them to the author(s) directly: http://pyodbc.sourceforge.net/ and click on "Bug tracker"
--
Gabriel Genellina
Thanks, I reported them there first and then posted here in case they
monitor the forum more frequently and so others would be aware of the
problems found.
Joe
"Gabriel Genellina" <ga*******@yaho o.com.arwrote in message
news:ma******** *************** *************** *@python.org...
En Fri, 18 May 2007 20:48:49 -0300, Joe Salmeri <Jo********@hot mail.com>
escribió:
>I believe this bug is also related to the other problem I just reported.
I think you'll get best results reporting them to the author(s) directly: http://pyodbc.sourceforge.net/ and click on "Bug tracker"
--
Gabriel Genellina This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: timw.google |
last post by:
I just downloaded the pyodbc source to try and install on my Linux FC3
box. I see that there is a setup.py file, but when I try to do a
'python setup.py build' (or just 'python setup.py') I get
Traceback (most recent call last):
File "setup.py", line 27, in ?
revision = latest_revision('.')
File "setup.py", line 25, in latest_revision
return int(output)
ValueError: invalid literal for int(): exported
|
by: king kikapu |
last post by:
Hi to all,
can anyone give me a jump-start about how to call Stored Procedures
from PyODBC ??
I want to execute a very simple testing Stored Procedure on an Sql
Server database.
I started using PyODBC and code like the following
cnxn = pyodbc.connect('DRIVER={SQL
|
by: timw.google |
last post by:
How do I get a list of datasources with pyodbc? I know that with
mx.ODBC.Windows I can use the DataSources method to get a dictionay
containing the datasources. Is there a similar way to do this with
pyodbc?
Thanks in advance.
|
by: Joe Salmeri |
last post by:
I have found a data corruption problem with pyodbc.
OS = Windows XP SP2
DB = Microsoft Access XP
PROBLEM:
When selecting columns from a table that are of type Memo the value
returned is padded with a bunch of null characters at the end.
|
by: Rajendran |
last post by:
Hi all,
I've installed pyodbc module to access my database (MS Access). I've
setup a User level DSN to the database.mdb file. When I run my python
code in the command prompt it is retrieving the database contents and
displaying it (HTML output).
But when I run that python from webserver (http://localhost/cgi-bin/
database.py) there comes an entry in the error log of Apache server
that says:
| |
by: Sean Davis |
last post by:
I have read a couple of blogs suggesting that pyodbc is buildable
under linux. I am running suse 10.2 on a 64-bit intel machine with
unixODBC installed. Upon building, I get a slew of pretty horrid
looking errors that make me wonder if this is supposed to work. Can
anyone at least confirm that this is possible before I try to pursue
things further?
Thanks,
Sean
|
by: bartonc |
last post by:
This is a work in progress (current and active).
There are some issues to resolve in supporting multiple connection types and I plan to add PySQLite to the mix. The this update is due to my suggesting the accompanying helper functions in a recent post and noticing that the ones posted here are a bit out of date. I'll post those helpers in a separate thread.
I've also been working with the following database engines:
MySQL 5.x
SQLite3
JET...
|
by: john.goodleaf |
last post by:
I've just built pyodbc 2.0.58 against freetds and unixodbc. When I
attempt to invoke it, either from the test script or from the
interpreter, I get:
ImportError: build/lib.linux-x86_64-2.5/pyodbc.so: undefined symbol:
PyUnicodeUCS2_Resize
I'm not quite sure how to go about troubleshooting this.
More info:
Build is on opensuse 11.0, intel x86_64 from Python 2.5.2. I've also
|
by: dj |
last post by:
Hello,
I have just started working with minimock in doctest.
I want to create a mock pyodbc object which returns a string value
when the method execute is called.
Here is my doctest:
.... ServerName = 'test_server'
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |