Pyodbc programming error while using Sybase

233 views
Skip to first unread message

Ishan Shah

unread,
Jul 5, 2019, 10:11:30 AM7/5/19
to sqlalchemy
I am using the Sybase dialect and trying to read an existing table. After loading the users table as follows, I use the query function to print all the records but I am getting a programming error which is related to pyodbc. My guess is that there is a syntax error here. How do I overcome this? Kindly advise.

users = Table("Users", metadata, autoload=True, autoload_with=engine, schema='dbo')
session.query(users).all()

ProgrammingError: (pyodbc.ProgrammingError) ('42000', "[42000] [FreeTDS][SQL Server]Incorrect syntax near 'dbo.Users.'.\n (102) (SQLExecDirectW)")
[SQL: SELECT dbo."Users".user_id AS "dbo_Users_user_id", dbo."Users".windows_id AS "dbo_Users_windows_id", dbo."Users".first_name AS "dbo_Users_first_name", dbo."Users".last_name AS "dbo_Users_last_name", dbo."Users".user_type AS "dbo_Users_user_type", dbo."Users".domain AS "dbo_Users_domain", dbo."Users".active AS "dbo_Users_active"
FROM dbo."Users"]

Mike Bayer

unread,
Jul 5, 2019, 10:19:57 AM7/5/19
to noreply-spamdigest via sqlalchemy
Unfortunately the Sybase dialect is not supported right now, but also I don't see anything obviously wrong with the query you have, except perhaps Sybase doesn't like that you have a table named "Users" that is using quoting; it is possible that it wants a different quoting character, not sure.  Or perhaps you should be omitting the "dbo" schema, which should be the defaul schema in any case.   Sorry I can't be of more help.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
 
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ishan Shah

unread,
Jul 5, 2019, 10:31:29 AM7/5/19
to sqlalchemy
Thanks for the prompt reply!

Since this page (https://docs.sqlalchemy.org/en/13/dialects/sybase.html) stated that Sybase is supported but there might be issues, I tried testing it. Do you mean to say that there is no support at all?

I was able to print out the column names in the tables using "users.columns".

I tried omitting the dbo "schema" but then I get a "NoSuchTableError", so I guess I need that. 

I appreciate your input. Thanks a lot!

On Friday, July 5, 2019 at 10:19:57 AM UTC-4, Mike Bayer wrote:
Unfortunately the Sybase dialect is not supported right now, but also I don't see anything obviously wrong with the query you have, except perhaps Sybase doesn't like that you have a table named "Users" that is using quoting; it is possible that it wants a different quoting character, not sure.  Or perhaps you should be omitting the "dbo" schema, which should be the defaul schema in any case.   Sorry I can't be of more help.


On Fri, Jul 5, 2019, at 10:11 AM, Ishan Shah wrote:
I am using the Sybase dialect and trying to read an existing table. After loading the users table as follows, I use the query function to print all the records but I am getting a programming error which is related to pyodbc. My guess is that there is a syntax error here. How do I overcome this? Kindly advise.

users = Table("Users", metadata, autoload=True, autoload_with=engine, schema='dbo')
session.query(users).all()

ProgrammingError: (pyodbc.ProgrammingError) ('42000', "[42000] [FreeTDS][SQL Server]Incorrect syntax near 'dbo.Users.'.\n (102) (SQLExecDirectW)")
[SQL: SELECT dbo."Users".user_id AS "dbo_Users_user_id", dbo."Users".windows_id AS "dbo_Users_windows_id", dbo."Users".first_name AS "dbo_Users_first_name", dbo."Users".last_name AS "dbo_Users_last_name", dbo."Users".user_type AS "dbo_Users_user_type", dbo."Users".domain AS "dbo_Users_domain", dbo."Users".active AS "dbo_Users_active"
FROM dbo."Users"]


--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
 
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlal...@googlegroups.com.

Mike Bayer

unread,
Jul 5, 2019, 12:05:15 PM7/5/19
to noreply-spamdigest via sqlalchemy


On Fri, Jul 5, 2019, at 10:31 AM, Ishan Shah wrote:
Thanks for the prompt reply!

Since this page (https://docs.sqlalchemy.org/en/13/dialects/sybase.html) stated that Sybase is supported but there might be issues, I tried testing it. Do you mean to say that there is no support at all?

I'm re-reading that and I guess the first title that reads "support for the Sybase dialect" is where you may have seen that this is "supported" ?    I'd very much like to take the Sybase dialect out entirely because the database itself is unusable in a CI context and I don't have the resources to handle it, but I assume some people use it somewhat successfully within a limited scope of use cases.  But because I can't run the database, I can't test your query, so I can't diagnose what the problem is.

I will update the verbiage to be clear that this database cannot be supported at this time.

To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.

Ishan Shah

unread,
Jul 5, 2019, 2:52:26 PM7/5/19
to sqlalchemy

Yes, that is where I read that Sybase is currently supported. Thank you for the quick assistance and making it clear. 
Reply all
Reply to author
Forward
0 new messages