[sqlalchemy] SQLAlchemy+pymssql unicode problem

2010-07-23 Thread Massi
Hi everyone,

I'm trying to write a small script to get all the table names from
SQLServer database (with pymssql). Up to now the script is really
simple:

engine = create_engine(mssql+pymssql://user:passw...@db_host/
db_name, encoding=cp1252)
metadata = MetaData(engine, reflect=True)
tabs = metadata.tables.keys()
print tabs

When I try to run this script I get the following error:

Traceback (most recent call last):
  File DBScript.py, line 12, in module
metadata = MetaData(engine, reflect=True)
  File D:\Program Files\Python26\Lib\site-packages\sqlalchemy
\schema.py, line
1788, in __init__
self.reflect()
  File D:\Program Files\Python26\Lib\site-packages\sqlalchemy
\schema.py, line
1915, in reflect
Table(name, self, **reflect_opts)
  File D:\Program Files\Python26\Lib\site-packages\sqlalchemy
\schema.py, line
207, in __new__
table._init(name, metadata, *args, **kw)
  File D:\Program Files\Python26\Lib\site-packages\sqlalchemy
\schema.py, line
261, in _init
reflecttable(self, include_columns=include_columns)
  File D:\Program Files\Python26\Lib\site-packages\sqlalchemy\engine
\base.py,
line 1776, in reflecttable
self.dialect.reflecttable(conn, table, include_columns)
  File D:\Program Files\Python26\Lib\site-packages\sqlalchemy\engine
\default.py
, line 217, in reflecttable
return insp.reflecttable(table, include_columns)
  File D:\Program Files\Python26\lib\site-packages\sqlalchemy\engine
\reflection
.py, line 411, in reflecttable
raise exc.NoSuchTableError(table.name)
sqlalchemy.exc.NoSuchTableError

I found that this error is due to a table in my DB called Attività,
so I believe that it is related to a unicode issue. Does anyone have
any idea about this error? Thanks in advance for your help!

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] SQLAlchemy+pymssql unicode problem

2010-07-23 Thread Michael Bayer
The version of SQLAlchemy and pymssql is very significant here.Older 
pymssqls didn't really support unicode at all.  The current one, unclear, we 
have basic dialect support for the latest pymssql in 0.6 but it hasn't been 
strongly tested.

There is of course very good support for pyodbc which runs on all platforms.

On Jul 23, 2010, at 7:42 AM, Massi wrote:

 Hi everyone,
 
 I'm trying to write a small script to get all the table names from
 SQLServer database (with pymssql). Up to now the script is really
 simple:
 
 engine = create_engine(mssql+pymssql://user:passw...@db_host/
 db_name, encoding=cp1252)
 metadata = MetaData(engine, reflect=True)
 tabs = metadata.tables.keys()
 print tabs
 
 When I try to run this script I get the following error:
 
 Traceback (most recent call last):
  File DBScript.py, line 12, in module
metadata = MetaData(engine, reflect=True)
  File D:\Program Files\Python26\Lib\site-packages\sqlalchemy
 \schema.py, line
 1788, in __init__
self.reflect()
  File D:\Program Files\Python26\Lib\site-packages\sqlalchemy
 \schema.py, line
 1915, in reflect
Table(name, self, **reflect_opts)
  File D:\Program Files\Python26\Lib\site-packages\sqlalchemy
 \schema.py, line
 207, in __new__
table._init(name, metadata, *args, **kw)
  File D:\Program Files\Python26\Lib\site-packages\sqlalchemy
 \schema.py, line
 261, in _init
reflecttable(self, include_columns=include_columns)
  File D:\Program Files\Python26\Lib\site-packages\sqlalchemy\engine
 \base.py,
 line 1776, in reflecttable
self.dialect.reflecttable(conn, table, include_columns)
  File D:\Program Files\Python26\Lib\site-packages\sqlalchemy\engine
 \default.py
 , line 217, in reflecttable
return insp.reflecttable(table, include_columns)
  File D:\Program Files\Python26\lib\site-packages\sqlalchemy\engine
 \reflection
 .py, line 411, in reflecttable
raise exc.NoSuchTableError(table.name)
 sqlalchemy.exc.NoSuchTableError
 
 I found that this error is due to a table in my DB called Attività,
 so I believe that it is related to a unicode issue. Does anyone have
 any idea about this error? Thanks in advance for your help!
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To post to this group, send email to sqlalch...@googlegroups.com.
 To unsubscribe from this group, send email to 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.
 

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.