Hi!

I am using SQLAlchemy 0.9.8 and py-postgresql 1.1.0.  

When I used the Column name without parentheses, it works perfectly.  
But, the following code receives KeyError.

from sqlalchemy import create_engine, Table, Column, Integer, Float, String, 
MetaData
engine = 
create_engine("postgresql+pypostgresql://tester:xxxxx@localhost/test_db")
engine.execute("DROP TABLE IF EXISTS test_table")
metadata = MetaData()
users = Table('test_table', metadata,
              Column('E(1)', String),
              Column('E(2)', Float),
              Column('E[3]', Integer)
              )
metadata.create_all(engine)
ins = users.insert().values(
    {'E(1)': "FOO", 'E(2)': 1000.0, 'E[3]': 5})
conn = engine.connect()
result = conn.execute(ins)
result.close()


The error is as follows
Traceback (most recent call last):
  File 
"/Users/hoge/PycharmProjects/sqlalchemy_tutorial/PostgreSQL_test.py", line 
30, in <module>
    result = conn.execute(ins)
  File 
"/Users/hoge/pyvenv/anaconda3/lib/python3.4/site-packages/sqlalchemy/engine/base.py",
 
line 729, in execute
    return meth(self, multiparams, params)
  File 
"/Users/hoge/pyvenv/anaconda3/lib/python3.4/site-packages/sqlalchemy/sql/elements.py",
 
line 322, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File 
"/Users/hoge/pyvenv/anaconda3/lib/python3.4/site-packages/sqlalchemy/engine/base.py",
 
line 826, in _execute_clauseelement
    compiled_sql, distilled_params
  File 
"/Users/hoge/pyvenv/anaconda3/lib/python3.4/site-packages/sqlalchemy/engine/base.py",
 
line 958, in _execute_context
    context)
  File 
"/Users/hoge/pyvenv/anaconda3/lib/python3.4/site-packages/sqlalchemy/engine/base.py",
 
line 1162, in _handle_dbapi_exception
    util.reraise(*exc_info)
  File 
"/Users/hoge/pyvenv/anaconda3/lib/python3.4/site-packages/sqlalchemy/util/compat.py",
 
line 182, in reraise
    raise value
  File 
"/Users/hoge/pyvenv/anaconda3/lib/python3.4/site-packages/sqlalchemy/engine/base.py",
 
line 951, in _execute_context
    context)
  File 
"/Users/hoge/pyvenv/anaconda3/lib/python3.4/site-packages/sqlalchemy/engine/default.py",
 
line 436, in do_execute
    cursor.execute(statement, parameters)
  File 
"/Users/hoge/.pyenv/versions/anaconda3-2.1.0/lib/python3.4/site-packages/postgresql/driver/dbapi20.py",
 
line 264, in execute
    sql, pxf, nparams = self._convert_query(statement)
  File 
"/Users/hoge/.pyenv/versions/anaconda3-2.1.0/lib/python3.4/site-packages/postgresql/driver/dbapi20.py",
 
line 244, in _convert_query
    rparts.append(part % kmap)
KeyError: 'E(1)'

Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to