This is a bug (you've just discovered it, thanks !).   I've added ticket #2181 
for this and I'm hoping to do a pass for 0.7.1 this weekend.   The issue is 
specific to windows and MySQL (not a platform we get as much opportunity to 
test on...).

I would be curious, if you are naming the table as:   Table("MyTable", ...), 
i.e. with mixed case.   If you put the name as all lower case, 
i.e.Table("mytable", ...),  that might resolve this.    Otherwise, the issue 
should not be present in 0.6.7 as that particular dictionary is not immutable 
in 0.6.

Or if you feel like patching, this patch will probably work:

diff -r 8a9b42709726 lib/sqlalchemy/dialects/mysql/base.py
--- a/lib/sqlalchemy/dialects/mysql/base.py     Thu Jun 02 03:09:08 2011 -0400
+++ b/lib/sqlalchemy/dialects/mysql/base.py     Thu Jun 02 11:13:22 2011 -0400
@@ -1982,8 +1982,7 @@
         # For winxx database hosts.  TODO: is this really needed?
         if casing == 1 and table.name != table.name.lower():
             table.name = table.name.lower()
-            lc_alias = sa_schema._get_table_key(table.name, table.schema)
-            table.metadata.tables[lc_alias] = table
+            table.metadata._add_table(table.name, table.schema, table)
 
     def _detect_charset(self, connection):
         raise NotImplementedError()



   
On Jun 2, 2011, at 3:41 AM, zhwolf wrote:

> Hi,
> I experienced the exception while accessing a mysql database in
> windows via sqlalchemy0.7.0.
> 
> It should be due to source code error in 0.7.0:
> The member tables of class MetaData is created as immutabledict,
>    sqlalchemy\schema.py::line 2181
>     self.tables = util.immutabledict()
> But the follow code try to change it's content:
>     sqlalchemy\dialects\mysql\base.py::line 1986
>           table.metadata.tables[lc_alias] = table
> 
> Could any people assist to resolve this issue?
> 
> Thanks,
> 
> log:
> mysql://root:root@127.0.0.1/linelocationdb?charset=utf8&use_unicode=0
> Traceback (most recent call last):
>  File "d:\python25\lib\site-packages\sqlalchemy-0.7.0-py2.5.egg
> \sqlalchemy\schema.py", line 263, in __new__   table._init(name,
> metadata, *args, **kw)
>  File "d:\python25\lib\site-packages\sqlalchemy-0.7.0-py2.5.egg
> \sqlalchemy\schema.py", line 329, in _init
>    reflecttable(self, include_columns=include_columns)
>  File "d:\python25\lib\site-packages\sqlalchemy-0.7.0-py2.5.egg
> \sqlalchemy\engine\base.py", line 2132, in reflecttable
>    self.dialect.reflecttable(conn, table, include_columns)
>  File "d:\python25\lib\site-packages\sqlalchemy-0.7.0-py2.5.egg
> \sqlalchemy\engine\default.py", line 254, in reflecttable
>    return insp.reflecttable(table, include_columns)
>  File "d:\python25\lib\site-packages\sqlalchemy-0.7.0-py2.5.egg
> \sqlalchemy\engine\reflection.py", line 353, in reflecttable
>    dialect._adjust_casing(table)
>  File "d:\python25\lib\site-packages\sqlalchemy-0.7.0-py2.5.egg
> \sqlalchemy\dialects\mysql\base.py", line 1986, in _adjust_casing
>    table.metadata.tables[lc_alias] = table
>  File "d:\python25\lib\site-packages\sqlalchemy-0.7.0-py2.5.egg
> \sqlalchemy\util\_collections.py", line 38, in _immutable
>    raise TypeError("%s object is immutable" %
> self.__class__.__name__)
> TypeError: immutabledict object is immutable
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@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 sqlalchemy@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.

Reply via email to