[egenix-users] mxODBC doesn't support LIMIT in SELECT?

Minh-Long Pham minh at mipscomputation.com
Tue Sep 2 13:46:25 CEST 2008


Hi,

It appears if I replace "LIMIT 5" with "LIMIT:5" the error goes away.
I'm pretty sure this is not the correct syntax for LIMIT, because when I
fetch it takes forever just to supposedly grab 5 rows (forever as in it
never takes me back to the prompt). The database I'm using is MAS90,
from Sage. I'm not sure it supports LIMIT.
So, yes, I've resorted to fetchmany() now.

Thanks for the reply,

Minh

M.-A. Lemburg wrote:
> On 2008-09-02 20:43, Minh-Long Pham wrote:
>   
>> Hi,
>>
>> I've connected to my database through mx.ODBC.Windows functions
>> connect() and DriverConnect().
>> I was able to execute sql.execute("""SELECT count(*) FROM
>> IM1_InventoryMasterfile""") but not
>> sql.execute("""SELECT * FROM IM1_InventoryMasterfile LIMIT 5""").
>>
>> This is the error that I get:
>> mx.ODBC.Error.InterfaceError: ('3700', 1017, '[Best Canada][PUX ODBC
>> Driver]Unexpected extra token: 5', 7089)
>>
>> Windows ODBC version: 3.525.11.32.0
>> Windows Python version: 2.5
>>
>> Why does a simple LIMIT 5 not work?
>>     
>
> Whether LIMIT works or not does not depend on mxODBC. This is a
> feature that your database backend must provide.
>
> Which database are you using ? Does it support LIMIT ?
>
> Note that you can easily fetch just the first 5 rows from the query
> using
>
>     cursor.fetchmany(5)
>
> This works even without LIMIT support in the database.
>
> Depending on the ODBC driver you are using, there are also other
> ways to further limit the number of rows that the ODBC driver
> fetches, e.g. using
>
>     cursor.setcursoroption(SQL.ATTR_MAX_ROWS, 5)
>
> If you want to move around in the result set without actually
> fetching rows over the network, you can use
>
>     cursor.scroll(value[,mode='relative'])
>
> However, whether this works depends on the capabilities of the
> ODBC driver.
>
>   



More information about the egenix-users mailing list