your MySQL-python build seems to be the problem. I would try upgrading.
mhearne808[insert-at-sign-here]gmail[insert-dot-here]com wrote: > > Hello - I am using SQLAlchemy as a part of the Enthought Python > Distribution. I'm getting an error while using metadata.drop_all() > with mysql, but not with sqlite. I was hoping someone could explain > what it is that I'm doing wrong. > > Version info: > Mac OS 10.5.7 > MySQL Ver 14.14 Distrib 5.1.34 > Python 2.5.4 -- EPD_Py25 4.2.30201 > SQLAlchemy 0.4.6 > > The sample code is below (you have to have a mysql database that you > are willing to try to destroy). The stack trace is below that. If I > replace driver='mysql' with driver='sqlite', I get no errors. > > The grants for the above user and database are as follows: > mysql> show grants for pager_wr...@localhost; > +-------------------------------------------------------------------------------------------------------------------- > + > | Grants for > pwr...@localhost > | > +-------------------------------------------------------------------------------------------------------------------- > + > | GRANT USAGE ON *.* TO 'pwrite'@'localhost' IDENTIFIED BY PASSWORD > '*FC4C8052E3C11C2C1FBB16180EFFFC36869B177E' | > | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON `sampledb`.* > TO 'pwrite'@'localhost' | > +-------------------------------------------------------------------------------------------------------------------- > + > 2 rows in set (0.00 sec) > > > #####code########## > #!/usr/bin/env python > > from sqlalchemy.orm import sessionmaker > from sqlalchemy import * > import sqlalchemy.exceptions > > driver = 'mysql' > user = 'pwrite' > password = 'rwrite' > host = 'localhost' > database = 'sampledb' > > if driver == 'mysql': > connectionURL = '%s://%s:%...@%s/%s' % > (driver,user,password,host,database) > > if driver == 'sqlite': > connectionURL = '%s:///%s' % (driver,host) > > engine = create_engine(connectionURL,echo=True) > engine.connect() > Session = sqlalchemy.orm.sessionmaker(bind=engine, autoflush=True) > metadata = MetaData() > user_table = Table('user', metadata, > Column('id', Integer, primary_key=True), > Column('lastname', String(40)), > Column('firstname', String(100)), > Column('contact', String(25)), > Column('createdon', DateTime), > UniqueConstraint('lastname', > 'firstname','contact'), > mysql_engine='InnoDB' > ) > > metadata.drop_all(bind=engine) > #####code########## > > #####trace########## > Traceback (most recent call last): > File "./dbtest.py", line 33, in <module> > metadata.drop_all(bind=engine) > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/ > schema.py", line 1609, in drop_all > bind.drop(self, checkfirst=checkfirst, tables=tables) > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/engine/ > base.py", line 1144, in drop > self._run_visitor(self.dialect.schemadropper, entity, > connection=connection, **kwargs) > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/engine/ > base.py", line 1168, in _run_visitor > visitorcallable(self.dialect, conn, **kwargs).traverse(element) > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/sql/ > visitors.py", line 75, in traverse > return self._non_cloned_traversal(obj) > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/sql/ > visitors.py", line 134, in _non_cloned_traversal > self.traverse_single(target) > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/sql/ > visitors.py", line 35, in traverse_single > return meth(obj, **kwargs) > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/sql/ > compiler.py", line 912, in visit_metadata > collection = [t for t in metadata.table_iterator(reverse=True, > tables=self.tables) if (not self.checkfirst or self.dialect.has_table > (self.connection, t.name, schema=t.schema))] > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/ > databases/mysql.py", line 1578, in has_table > self._autoset_identifier_style(connection) > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/ > databases/mysql.py", line 1802, in _autoset_identifier_style > charset=charset)) > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/engine/ > base.py", line 844, in execute > return Connection.executors[c](self, object, multiparams, params) > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/engine/ > base.py", line 853, in _execute_text > context = self.__create_execution_context(statement=statement, > parameters=parameters) > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/engine/ > base.py", line 948, in __create_execution_context > return self.engine.dialect.create_execution_context > (connection=self, **kwargs) > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/ > databases/mysql.py", line 1474, in create_execution_context > return MySQLExecutionContext(self, connection, **kwargs) > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/engine/ > default.py", line 194, in __init__ > self.cursor = self.create_cursor() > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/engine/ > default.py", line 276, in create_cursor > return self._connection.connection.cursor() > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/SQLAlchemy-0.4.6n1-py2.5.egg/sqlalchemy/ > pool.py", line 370, in cursor > c = self.connection.cursor(*args, **kwargs) > File "/Library/Frameworks/Python.framework/Versions/4.2.30201/lib/ > python2.5/site-packages/MySQL_python-1.2.2n3-py2.5-macosx-10.3-fat.egg/ > MySQLdb/connections.py", line 226, in cursor > return (cursorclass or self.cursorclass)(self) > AttributeError: 'Connection' object has no attribute 'cursorclass' > #####trace########## > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---