SQLAlchemy+pymysql Error: sqlalchemy.util.queue.Empty
Question: Trying to run Python3.2, SQLAlchemy0.8 and MySQL5.2 on Ubuntu using Eclispse
but I keep getting the error below. Am using pymysql (pymysql3 actually)
engine.

**module monitor**

    
    
    from sqlalchemy import create_engine, MetaData
    from sqlalchemy.ext.declarative import declarative_base
    Engine = create_engine('mysql+pymysql://user:mypass@localhost/mydb')
    Base = declarative_base(Engine)
    Metadata = MetaData(bind=Engine)
    
    from sqlalchemy.orm import sessionmaker
    from sqlalchemy import Table, Column, Integer
    Session = sessionmaker(bind=Engine)
    session = Session()
    
    class Student(Base):
        __table__ = Table('student_name', Metadata,
        Column('id', Integer, primary_key=True),
        autoload=True)
    

With that, when I run the module it throws the error as indicated below. What
am I doing wrong?

    
    
    Traceback (most recent call last):
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/pool.py", line 757, in _do_get
    return self._pool.get(wait, self._timeout)
     File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/util/queue.py", line 166, in get
    raise Empty
    sqlalchemy.util.queue.Empty
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
    File "/home/lukik/workspace/upark/src/monitor.py", line 12, in <module>
    class Parking(Base):
    File "/home/lukik/workspace/upark/src/monitor.py", line 15, in Parking
    autoload=True)
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/schema.py", line 333, in __new__
    table._init(name, metadata, *args, **kw)
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/schema.py", line 397, in _init
    self._autoload(metadata, autoload_with, include_columns)
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/schema.py", line 425, in _autoload
    self, include_columns, exclude_columns
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/engine/base.py", line 1604, in run_callable
    with self.contextual_connect() as conn:
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/engine/base.py", line 1671, in contextual_connect
    self.pool.connect(),
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/pool.py", line 272, in connect
    return _ConnectionFairy(self).checkout()
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/pool.py", line 425, in __init__
    rec = self._connection_record = pool._do_get()
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/pool.py", line 777, in _do_get
    con = self._create_connection()
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/pool.py", line 225, in _create_connection
    return _ConnectionRecord(self)
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/pool.py", line 322, in __init__
    exec_once(self.connection, self)
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/event.py", line 381, in exec_once
    self(*args, **kw)
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/event.py", line 398, in __call__
    fn(*args, **kw)
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/engine/strategies.py", line 168, in first_connect
    dialect.initialize(c)
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/dialects/mysql/base.py", line 2052, in initialize
    default.DefaultDialect.initialize(self, connection)
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/engine/default.py", line 172, in initialize
    self._get_default_schema_name(connection)
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/dialects/mysql/base.py", line 2019, in _get_default_schema_name
    return connection.execute('SELECT DATABASE()').scalar()
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/engine/base.py", line 664, in execute
    params)
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/engine/base.py", line 808, in _execute_text
    statement, parameters
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/engine/base.py", line 871, in _execute_context
    context)
    File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/engine/default.py", line 322, in do_execute
    cursor.execute(statement, parameters)
    File "/usr/local/lib/python3.2/dist-packages/pymysql/cursors.py", line 105, in execute
    query = query % escaped_args
    TypeError: unsupported operand type(s) for %: 'bytes' and 'tuple'
    


Answer: `mysql-connector-python` and `oursql` work fine for me under py3k.

# How to install?

    
    
    $ pip install mysql-connector-python
    

# Usage

    
    
    Engine = create_engine('mysql+mysqlconnector://<USERNAME>:<PASSWD>@<HOSTNAME>:<PORT>/<DBNAME>')
    

