Hi,

I'm not sure if you're interested in this sort of report, but what the
heck. When I try to do a metadata.create_all(engine) on my relatively
simple 'declarative' class (see widget.py below), I get the backtrace
below if I'm using the latest (test) MySQL-python driver (1.2.3b1) (it
works fine with 1.2.2).  It would appear to be due to this line in
sqlalchemy/databases/mysql.py's 'has_table' function, as MySQL

 if e.orig.args[0] == 1146:

It appears that this should be:

 if e.orig.args[0][0] == 1146:

At least, when I make that change everything starts working.

Thanks,

-- Jacob

$ python widget.py
2009-02-11 16:22:21,255 INFO sqlalchemy.engine.base.Engine.0x...1e90
SHOW VARIABLES LIKE 'sql_mode'
2009-02-11 16:22:21,261 INFO sqlalchemy.engine.base.Engine.0x...1e90
()
2009-02-11 16:22:21,269 INFO sqlalchemy.engine.base.Engine.0x...1e90
DESCRIBE `widgets`
2009-02-11 16:22:21,269 INFO sqlalchemy.engine.base.Engine.0x...1e90
()
2009-02-11 16:22:21,270 INFO sqlalchemy.engine.base.Engine.0x...1e90
ROLLBACK
Traceback (most recent call last):
  File "widget.py", line 21, in <module>
    Base.metadata.create_all(engine)
  File "/home/jacob/Workspace/kits/future/output/site-packages/
SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/schema.py", line 1765, in cre\
ate_all
    bind.create(self, checkfirst=checkfirst, tables=tables)
  File "/home/jacob/Workspace/kits/future/output/site-packages/
SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/engine/base.py", line 1129, i\
n create
    self._run_visitor(self.dialect.schemagenerator, entity,
connection=connection, **kwargs)
  File "/home/jacob/Workspace/kits/future/output/site-packages/
SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/engine/base.py", line 1158, i\
n _run_visitor
    visitorcallable(self.dialect, conn, **kwargs).traverse(element)
  File "/home/jacob/Workspace/kits/future/output/site-packages/
SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/sql/visitors.py", line 89, in\
 traverse
    return traverse(obj, self.__traverse_options__,
self._visitor_dict)
  File "/home/jacob/Workspace/kits/future/output/site-packages/
SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/sql/visitors.py", line 200, i\
n traverse
    return traverse_using(iterate(obj, opts), obj, visitors)
  File "/home/jacob/Workspace/kits/future/output/site-packages/
SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/sql/visitors.py", line 194, i\
n traverse_using
    meth(target)
  File "/home/jacob/Workspace/kits/future/output/site-packages/
SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/sql/compiler.py", line 795, i\
n visit_metadata
    collection = [t for t in sql_util.sort_tables(tables) if
self._can_create(t)]
  File "/home/jacob/Workspace/kits/future/output/site-packages/
SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/sql/compiler.py", line 788, i\
n _can_create
    return not self.checkfirst or not self.dialect.has_table
(self.connection, table.name, schema=table.schema)
  File "/home/jacob/Workspace/kits/future/output/site-packages/
SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/databases/mysql.py", line 160\
7, in has_table
    rs = connection.execute(st)
  File "/home/jacob/Workspace/kits/future/output/site-packages/
SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/engine/base.py", line 824, in\
 execute
    return Connection.executors[c](self, object, multiparams, params)
  File "/home/jacob/Workspace/kits/future/output/site-packages/
SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/engine/base.py", line 888, in\
 _execute_text
    return self.__execute_context(context)
  File "/home/jacob/Workspace/kits/future/output/site-packages/
SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/engine/base.py", line 896, in\
 __execute_context
    self._cursor_execute(context.cursor, context.statement,
context.parameters[0], context=context)
  File "/home/jacob/Workspace/kits/future/output/site-packages/
SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/engine/base.py", line 950, in\
 _cursor_execute
    self._handle_dbapi_exception(e, statement, parameters, cursor,
context)
  File "/home/jacob/Workspace/kits/future/output/site-packages/
SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/engine/base.py", line 931, in\
 _handle_dbapi_exception
    raise exc.DBAPIError.instance(statement, parameters, e,
connection_invalidated=is_disconnect)
sqlalchemy.exc.ProgrammingError: (ProgrammingError) (1146, "Table
'thunderdome.widgets' doesn't exist") 'DESCRIBE `widgets`' ()

================================
# widget.py
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, String, MetaData
from sqlalchemy.databases import mysql

Base = declarative_base()
class Widget(Base):
    __tablename__ = 'widgets'

    widget_id = Column(String(64), primary_key=True)
    widget_text = Column(mysql.MSLongText, nullable=False)

    def __init__(self, widget_id, widget_text):
        self.widget_id = widget_id
        self.widget_text = widget_text

engine = create_engine('mysql://r...@localhost/thunderdome',
echo=True)
Base.metadata.create_all(engine)


--~--~---------~--~----~------------~-------~--~----~
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