Re: [sqlalchemy] Could not locate column in row for column
Hello, Mike thank you for your answer for now it works fine with the patch create_engine( description_encoding = 'utf8') 2014-06-20 22:36 GMT+04:00 Mike Bayer : > > On 6/20/14, 12:14 PM, Mike Bayer wrote: > > On 6/20/14, 7:32 AM, Mike Bayer wrote: > >> NoSuchColumnError: "Could not locate column in row for column > >> > '\\u0417\\u0430\\u043a\\u0430\\u0437\\u044b.\\u041d\\u043e\\u043c\\u0435\\u0440 > >> \\u0437\\u0430\\u043a\\u0430\\u0437\\u0430'" > >> > >> The problem is i can't really debug this error because it isn't clear > >> what should be in pk_cols > >> > >> Previously in orm/loading.py there is a string > >> pk_cols = mapper.primary_key # line number 250 > >> > >> So, pk_cols is a list of Column() objects. > >> row is a list of values from query > >> Surely, [row[column] for column in pk_cols] raises error, because > >> column is a Column() object and can't be index for row. But i can't > >> imagine how this code may work. Is this a bug? > >> the ResultProxy contains translation logic that receives Column objects > >> and locates the data by name. This is documented at > >> http://docs.sqlalchemy.org/en/rel_0_9/core/tutorial.html#selecting and > >> is the primary method by which the ORM relates mapped columns to result > >> sets. > >> > >> In this case the issue is most likely yet another pyodbc + unicode > >> encoding issue, of which there are many, and often there's no way to > >> work around. Need to know 1. OS platform 2. FreeTDS version 3. UnixODBC > >> or iODBC (and what version) 4. pyodbc version 5. SQL Server version. I > >> can try to test but often these unicode issues aren't easy to resolve > >> (have you tried pymssql? ).thanks. > > good news, I can reproduce this, and on my end at least it needs the > > so-called "description_encoding" workaround. We may have to revisit > > the defaults on this parameter for modern versions of Pyodbc. The test > > below produces your error without the param, resolves with it. Please > > try this out on your create_engine(), thanks. > > > > #! coding: utf-8 > > > > from sqlalchemy import * > > > > engine = create_engine("mssql+pyodbc://scott:tiger@ms_2008", echo=True, > > description_encoding='utf8') > > > > colname = u'Заказ.Номер заказа' > > > > m = MetaData() > > t = Table(u"Заказы", m, Column(colname, String(30), key='somecol')) > > > > m.drop_all(engine) > > m.create_all(engine) > > > > engine.execute(t.insert().values(somecol='some value')) > > result = engine.execute(t.select().where(t.c.somecol == 'some value')) > > row = result.fetchone() > > print row[t.c.somecol] > yeah this is the workaround for now, but totally this is a bug back to > 0.8 and further, should be backported for 0.8, 0.9 and 1.0 in > > https://bitbucket.org/zzzeek/sqlalchemy/issue/3091/update-description_encoding-for-pyodbc > . > Two different issues located. > > -- > You received this message because you are subscribed to a topic in the > Google Groups "sqlalchemy" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/sqlalchemy/svIe6UWMWyU/unsubscribe. > To unsubscribe from this group and all its topics, 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. > -- Счастливой радости! Тимур Ожегин -- 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.
Re: [sqlalchemy] Could not locate column in row for column
On 6/20/14, 12:14 PM, Mike Bayer wrote: > On 6/20/14, 7:32 AM, Mike Bayer wrote: >> NoSuchColumnError: "Could not locate column in row for column >> '\\u0417\\u0430\\u043a\\u0430\\u0437\\u044b.\\u041d\\u043e\\u043c\\u0435\\u0440 >> \\u0437\\u0430\\u043a\\u0430\\u0437\\u0430'" >> >> The problem is i can't really debug this error because it isn't clear >> what should be in pk_cols >> >> Previously in orm/loading.py there is a string >> pk_cols = mapper.primary_key # line number 250 >> >> So, pk_cols is a list of Column() objects. >> row is a list of values from query >> Surely, [row[column] for column in pk_cols] raises error, because >> column is a Column() object and can't be index for row. But i can't >> imagine how this code may work. Is this a bug? >> the ResultProxy contains translation logic that receives Column objects >> and locates the data by name. This is documented at >> http://docs.sqlalchemy.org/en/rel_0_9/core/tutorial.html#selecting and >> is the primary method by which the ORM relates mapped columns to result >> sets. >> >> In this case the issue is most likely yet another pyodbc + unicode >> encoding issue, of which there are many, and often there's no way to >> work around. Need to know 1. OS platform 2. FreeTDS version 3. UnixODBC >> or iODBC (and what version) 4. pyodbc version 5. SQL Server version. I >> can try to test but often these unicode issues aren't easy to resolve >> (have you tried pymssql? ).thanks. > good news, I can reproduce this, and on my end at least it needs the > so-called "description_encoding" workaround. We may have to revisit > the defaults on this parameter for modern versions of Pyodbc. The test > below produces your error without the param, resolves with it. Please > try this out on your create_engine(), thanks. > > #! coding: utf-8 > > from sqlalchemy import * > > engine = create_engine("mssql+pyodbc://scott:tiger@ms_2008", echo=True, > description_encoding='utf8') > > colname = u'Заказ.Номер заказа' > > m = MetaData() > t = Table(u"Заказы", m, Column(colname, String(30), key='somecol')) > > m.drop_all(engine) > m.create_all(engine) > > engine.execute(t.insert().values(somecol='some value')) > result = engine.execute(t.select().where(t.c.somecol == 'some value')) > row = result.fetchone() > print row[t.c.somecol] yeah this is the workaround for now, but totally this is a bug back to 0.8 and further, should be backported for 0.8, 0.9 and 1.0 in https://bitbucket.org/zzzeek/sqlalchemy/issue/3091/update-description_encoding-for-pyodbc. Two different issues located. -- 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.
Re: [sqlalchemy] Could not locate column in row for column
On 6/20/14, 7:32 AM, Mike Bayer wrote: > NoSuchColumnError: "Could not locate column in row for column > '\\u0417\\u0430\\u043a\\u0430\\u0437\\u044b.\\u041d\\u043e\\u043c\\u0435\\u0440 > \\u0437\\u0430\\u043a\\u0430\\u0437\\u0430'" > > The problem is i can't really debug this error because it isn't clear > what should be in pk_cols > > Previously in orm/loading.py there is a string > pk_cols = mapper.primary_key # line number 250 > > So, pk_cols is a list of Column() objects. > row is a list of values from query > Surely, [row[column] for column in pk_cols] raises error, because > column is a Column() object and can't be index for row. But i can't > imagine how this code may work. Is this a bug? > the ResultProxy contains translation logic that receives Column objects > and locates the data by name. This is documented at > http://docs.sqlalchemy.org/en/rel_0_9/core/tutorial.html#selecting and > is the primary method by which the ORM relates mapped columns to result > sets. > > In this case the issue is most likely yet another pyodbc + unicode > encoding issue, of which there are many, and often there's no way to > work around. Need to know 1. OS platform 2. FreeTDS version 3. UnixODBC > or iODBC (and what version) 4. pyodbc version 5. SQL Server version. I > can try to test but often these unicode issues aren't easy to resolve > (have you tried pymssql? ).thanks. good news, I can reproduce this, and on my end at least it needs the so-called "description_encoding" workaround. We may have to revisit the defaults on this parameter for modern versions of Pyodbc. The test below produces your error without the param, resolves with it. Please try this out on your create_engine(), thanks. #! coding: utf-8 from sqlalchemy import * engine = create_engine("mssql+pyodbc://scott:tiger@ms_2008", echo=True, description_encoding='utf8') colname = u'Заказ.Номер заказа' m = MetaData() t = Table(u"Заказы", m, Column(colname, String(30), key='somecol')) m.drop_all(engine) m.create_all(engine) engine.execute(t.insert().values(somecol='some value')) result = engine.execute(t.select().where(t.c.somecol == 'some value')) row = result.fetchone() print row[t.c.somecol] -- 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.
Re: [sqlalchemy] Could not locate column in row for column
On 6/20/14, 3:59 AM, Belegnar Dragon wrote: > Hello. > > SQLAlchemy 0.9.4 > > In this code > > def unidecode_column_name(inspector, table, column_info): > column_info['key'] = unidecode(column_info['name']).replace(u' ', > u'_') > > engine = create_engine("mssql+pyodbc://%s:%s@RTBD" % > (settings.RT_USER, settings.RT_PWD), echo = True) > metadata = MetaData(bind = engine) > metadata.reflect(engine, only = [u"Заказы",], listeners = > [('column_reflect', unidecode_column_name)]) > orders = metadata.tables[u'Заказы'] > class Order(object): > pass > mapper(Order, orders) > > sess = Session(engine) > q = sess.query(Order) > q.filter_by(Kod_zakazchika = u'F07301m').all() > > I've got the following error > > NoSuchColumnError Traceback (most recent call > last) > in () > > 1 q.filter_by(Kod_zakazchika = u'F07301m').all() > > local/lib/python2.7/site-packages/sqlalchemy/orm/query.pyc in all(self) >2290 >2291 """ > -> 2292 return list(self) >2293 >2294 @_generative(_no_clauseelement_condition) > > local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py in > instances(query, cursor, context) > 70 process[0](row, rows) > 71 elif single_entity: > ---> 72 rows = [process[0](row, None) for row in fetch] > 73 else: > 74 rows = [util.KeyedTuple([proc(row, None) for proc > in process], > > local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py in > _instance(row, result) > 359 identitykey = ( > 360 identity_class, > --> 361 tuple([row[column] for column in > pk_cols]) > 362 ) > 363 > > local/lib/python2.7/site-packages/sqlalchemy/engine/result.pyc in > _key_fallback(self, key, raiseerr) > 330 raise exc.NoSuchColumnError( > 331 "Could not locate column in row for column > '%s'" % > --> 332 expression._string_or_unprintable(key)) > 333 else: > 334 return None > > NoSuchColumnError: "Could not locate column in row for column > '\\u0417\\u0430\\u043a\\u0430\\u0437\\u044b.\\u041d\\u043e\\u043c\\u0435\\u0440 > \\u0437\\u0430\\u043a\\u0430\\u0437\\u0430'" > > The problem is i can't really debug this error because it isn't clear > what should be in pk_cols > > Previously in orm/loading.py there is a string > pk_cols = mapper.primary_key # line number 250 > > So, pk_cols is a list of Column() objects. > row is a list of values from query > Surely, [row[column] for column in pk_cols] raises error, because > column is a Column() object and can't be index for row. But i can't > imagine how this code may work. Is this a bug? the ResultProxy contains translation logic that receives Column objects and locates the data by name. This is documented at http://docs.sqlalchemy.org/en/rel_0_9/core/tutorial.html#selecting and is the primary method by which the ORM relates mapped columns to result sets. In this case the issue is most likely yet another pyodbc + unicode encoding issue, of which there are many, and often there's no way to work around. Need to know 1. OS platform 2. FreeTDS version 3. UnixODBC or iODBC (and what version) 4. pyodbc version 5. SQL Server version. I can try to test but often these unicode issues aren't easy to resolve (have you tried pymssql? ).thanks. -- 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.
[sqlalchemy] Could not locate column in row for column
Hello. SQLAlchemy 0.9.4 In this code def unidecode_column_name(inspector, table, column_info): column_info['key'] = unidecode(column_info['name']).replace(u' ', u'_') engine = create_engine("mssql+pyodbc://%s:%s@RTBD" % (settings.RT_USER, settings.RT_PWD), echo = True) metadata = MetaData(bind = engine) metadata.reflect(engine, only = [u"Заказы",], listeners = [('column_reflect', unidecode_column_name)]) orders = metadata.tables[u'Заказы'] class Order(object): pass mapper(Order, orders) sess = Session(engine) q = sess.query(Order) q.filter_by(Kod_zakazchika = u'F07301m').all() I've got the following error NoSuchColumnError Traceback (most recent call last) in () > 1 q.filter_by(Kod_zakazchika = u'F07301m').all() local/lib/python2.7/site-packages/sqlalchemy/orm/query.pyc in all(self) 2290 2291 """ -> 2292 return list(self) 2293 2294 @_generative(_no_clauseelement_condition) local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py in instances(query, cursor, context) 70 process[0](row, rows) 71 elif single_entity: ---> 72 rows = [process[0](row, None) for row in fetch] 73 else: 74 rows = [util.KeyedTuple([proc(row, None) for proc in process], local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py in _instance(row, result) 359 identitykey = ( 360 identity_class, --> 361 tuple([row[column] for column in pk_cols]) 362 ) 363 local/lib/python2.7/site-packages/sqlalchemy/engine/result.pyc in _key_fallback(self, key, raiseerr) 330 raise exc.NoSuchColumnError( 331 "Could not locate column in row for column '%s'" % --> 332 expression._string_or_unprintable(key)) 333 else: 334 return None NoSuchColumnError: "Could not locate column in row for column '\\u0417\\u0430\\u043a\\u0430\\u0437\\u044b.\\u041d\\u043e\\u043c\\u0435\\u0440 \\u0437\\u0430\\u043a\\u0430\\u0437\\u0430'" The problem is i can't really debug this error because it isn't clear what should be in pk_cols Previously in orm/loading.py there is a string pk_cols = mapper.primary_key # line number 250 So, pk_cols is a list of Column() objects. row is a list of values from query Surely, [row[column] for column in pk_cols] raises error, because column is a Column() object and can't be index for row. But i can't imagine how this code may work. Is this a bug? -- WBR, Belegnar -- 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.
Re: [sqlalchemy] Could not locate column in row for column
updated pymysql to version 0.6.1 and it worked for me. thx alot 2014-02-12 19:27 GMT+02:00 Michael Bayer : > And you updated pymysql? Or no? > > Sent from my iPhone > > On Feb 12, 2014, at 10:56 AM, Igal Kreimer wrote: > > yes it does. exactly the same problem, copy pasted ur code and received: > > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", > line 2264, in all > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", > line 75, in instances > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", > line 75, in > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", > line 74, in > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", > line 3440, in proc > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", > line 71, in __getitem__ > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", > line 317, in _key_fallback > sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for > column 'a.id'" > > > 2014-02-12 16:26 GMT+02:00 Michael Bayer : > >> >> On Feb 12, 2014, at 4:49 AM, Igal Kreimer wrote: >> >> > Hello sqlalchemy team. >> > >> > im a new user to the alchemy, and doing the tutorial on ur site. >> > ran ur tutorial on adding information to databases and querying against >> a virtual db (sqlite in memory) >> > >> > after i thought i got that, i tried testing against a real db - mysql >> db. >> > im using the driver of pymysql version 0.4 (i know its kinda old, but >> when was using newer version i had other bugs, not related to this topic). >> >> OK well definitely get on the latest pymysql, that driver is not super >> mature so you want to be on the latest. I tried 0.6.1 here and can't >> reproduce your issue. >> >> >> > >> > Traceback (most recent call last): >> > File "J:/working_dir/TLM/lib/DB_Wrapper/Lab_DB/DB_Reader.py", line >> 39, in >> > read_from_DB() >> > File "J:/working_dir/TLM/lib/DB_Wrapper/Lab_DB/DB_Reader.py", line >> 26, in read_from_DB >> > print(str(session.query(CpuTable.id.label('id')).all())) >> > File >> "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", >> line 2264, in all >> > File >> "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", >> line 75, in instances >> > File >> "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", >> line 75, in >> > File >> "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", >> line 74, in >> > File >> "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", >> line 3440, in proc >> > File >> "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", >> line 71, in __getitem__ >> > File >> "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", >> line 317, in _key_fallback >> > sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for >> column 'cpu.id'" >> >> yes that's a totally strange issue that I cannot reproduce, running SQLA >> 0.9.0 / py3.3 / pymysql. >> >> one thing that *may* be going wrong is that I see you're on windows, and >> there might be case sensitivity issues happening. Though I'm not really >> sure how, I can use any name for the label and of course it works. >> >> here's the test case I'm using, you get the same results with this? >> >> from sqlalchemy import * >> from sqlalchemy.orm import * >> from sqlalchemy.ext.declarative import declarative_base >> >> Base = declarative_base() >> >> class A(Base): >> __tablename__ = 'a' >> >> id = Column(Integer, primary_key=True) >> >> e = create_engine("mysql+pymysql://scott:tiger@localhost/test", >> echo=True) >> Base.metadata.drop_all(e) >> Base.metadata.create_all(e) >> >> sess = Session(e) >> sess.add_all([A(), A(), A()]) >> >> print(sess.query(A.id.label('id')).all()) >> print(sess.query(A.id.label('foobar')).all()) >> >> >> >> > -- > 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/groups/opt_out. > > -- > You received this message because you are subscribed to a topic in the > Google Groups "sqlalchemy" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/sqlalchemy/Csp5gF0NBxw/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > sqlalchemy+unsubscr...@googlegroups.com. > To post t
Re: [sqlalchemy] Could not locate column in row for column
And you updated pymysql? Or no? Sent from my iPhone > On Feb 12, 2014, at 10:56 AM, Igal Kreimer wrote: > > yes it does. exactly the same problem, copy pasted ur code and received: > > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", > line 2264, in all > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", > line 75, in instances > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", > line 75, in > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", > line 74, in > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", > line 3440, in proc > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", > line 71, in __getitem__ > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", > line 317, in _key_fallback > sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for column > 'a.id'" > > > 2014-02-12 16:26 GMT+02:00 Michael Bayer : >> >> On Feb 12, 2014, at 4:49 AM, Igal Kreimer wrote: >> >> > Hello sqlalchemy team. >> > >> > im a new user to the alchemy, and doing the tutorial on ur site. >> > ran ur tutorial on adding information to databases and querying against a >> > virtual db (sqlite in memory) >> > >> > after i thought i got that, i tried testing against a real db - mysql db. >> > im using the driver of pymysql version 0.4 (i know its kinda old, but when >> > was using newer version i had other bugs, not related to this topic). >> >> OK well definitely get on the latest pymysql, that driver is not super >> mature so you want to be on the latest. I tried 0.6.1 here and can’t >> reproduce your issue. >> >> >> > >> > Traceback (most recent call last): >> > File "J:/working_dir/TLM/lib/DB_Wrapper/Lab_DB/DB_Reader.py", line 39, >> > in >> > read_from_DB() >> > File "J:/working_dir/TLM/lib/DB_Wrapper/Lab_DB/DB_Reader.py", line 26, >> > in read_from_DB >> > print(str(session.query(CpuTable.id.label('id')).all())) >> > File >> > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", >> > line 2264, in all >> > File >> > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", >> > line 75, in instances >> > File >> > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", >> > line 75, in >> > File >> > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", >> > line 74, in >> > File >> > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", >> > line 3440, in proc >> > File >> > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", >> > line 71, in __getitem__ >> > File >> > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", >> > line 317, in _key_fallback >> > sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for >> > column 'cpu.id’" >> >> yes that’s a totally strange issue that I cannot reproduce, running SQLA >> 0.9.0 / py3.3 / pymysql. >> >> one thing that *may* be going wrong is that I see you’re on windows, and >> there might be case sensitivity issues happening. Though I’m not really >> sure how, I can use any name for the label and of course it works. >> >> here’s the test case I’m using, you get the same results with this? >> >> from sqlalchemy import * >> from sqlalchemy.orm import * >> from sqlalchemy.ext.declarative import declarative_base >> >> Base = declarative_base() >> >> class A(Base): >> __tablename__ = 'a' >> >> id = Column(Integer, primary_key=True) >> >> e = create_engine("mysql+pymysql://scott:tiger@localhost/test", echo=True) >> Base.metadata.drop_all(e) >> Base.metadata.create_all(e) >> >> sess = Session(e) >> sess.add_all([A(), A(), A()]) >> >> print(sess.query(A.id.label('id')).all()) >> print(sess.query(A.id.label('foobar')).all()) > > -- > 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/groups/opt_out. -- 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://grou
Re: [sqlalchemy] Could not locate column in row for column
yes it does. exactly the same problem, copy pasted ur code and received: File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", line 2264, in all File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", line 75, in instances File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", line 75, in File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", line 74, in File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", line 3440, in proc File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", line 71, in __getitem__ File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", line 317, in _key_fallback sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for column 'a.id'" 2014-02-12 16:26 GMT+02:00 Michael Bayer : > > On Feb 12, 2014, at 4:49 AM, Igal Kreimer wrote: > > > Hello sqlalchemy team. > > > > im a new user to the alchemy, and doing the tutorial on ur site. > > ran ur tutorial on adding information to databases and querying against > a virtual db (sqlite in memory) > > > > after i thought i got that, i tried testing against a real db - mysql db. > > im using the driver of pymysql version 0.4 (i know its kinda old, but > when was using newer version i had other bugs, not related to this topic). > > OK well definitely get on the latest pymysql, that driver is not super > mature so you want to be on the latest. I tried 0.6.1 here and can't > reproduce your issue. > > > > > > Traceback (most recent call last): > > File "J:/working_dir/TLM/lib/DB_Wrapper/Lab_DB/DB_Reader.py", line 39, > in > > read_from_DB() > > File "J:/working_dir/TLM/lib/DB_Wrapper/Lab_DB/DB_Reader.py", line 26, > in read_from_DB > > print(str(session.query(CpuTable.id.label('id')).all())) > > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", > line 2264, in all > > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", > line 75, in instances > > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", > line 75, in > > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", > line 74, in > > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", > line 3440, in proc > > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", > line 71, in __getitem__ > > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", > line 317, in _key_fallback > > sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for > column 'cpu.id'" > > yes that's a totally strange issue that I cannot reproduce, running SQLA > 0.9.0 / py3.3 / pymysql. > > one thing that *may* be going wrong is that I see you're on windows, and > there might be case sensitivity issues happening. Though I'm not really > sure how, I can use any name for the label and of course it works. > > here's the test case I'm using, you get the same results with this? > > from sqlalchemy import * > from sqlalchemy.orm import * > from sqlalchemy.ext.declarative import declarative_base > > Base = declarative_base() > > class A(Base): > __tablename__ = 'a' > > id = Column(Integer, primary_key=True) > > e = create_engine("mysql+pymysql://scott:tiger@localhost/test", echo=True) > Base.metadata.drop_all(e) > Base.metadata.create_all(e) > > sess = Session(e) > sess.add_all([A(), A(), A()]) > > print(sess.query(A.id.label('id')).all()) > print(sess.query(A.id.label('foobar')).all()) > > > > -- 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/groups/opt_out.
Re: [sqlalchemy] Could not locate column in row for column
On Feb 12, 2014, at 4:49 AM, Igal Kreimer wrote: > Hello sqlalchemy team. > > im a new user to the alchemy, and doing the tutorial on ur site. > ran ur tutorial on adding information to databases and querying against a > virtual db (sqlite in memory) > > after i thought i got that, i tried testing against a real db - mysql db. > im using the driver of pymysql version 0.4 (i know its kinda old, but when > was using newer version i had other bugs, not related to this topic). OK well definitely get on the latest pymysql, that driver is not super mature so you want to be on the latest. I tried 0.6.1 here and can’t reproduce your issue. > > Traceback (most recent call last): > File "J:/working_dir/TLM/lib/DB_Wrapper/Lab_DB/DB_Reader.py", line 39, in > > read_from_DB() > File "J:/working_dir/TLM/lib/DB_Wrapper/Lab_DB/DB_Reader.py", line 26, in > read_from_DB > print(str(session.query(CpuTable.id.label('id')).all())) > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", > line 2264, in all > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", > line 75, in instances > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", > line 75, in > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", > line 74, in > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", > line 3440, in proc > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", > line 71, in __getitem__ > File > "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", > line 317, in _key_fallback > sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for column > 'cpu.id’" yes that’s a totally strange issue that I cannot reproduce, running SQLA 0.9.0 / py3.3 / pymysql. one thing that *may* be going wrong is that I see you’re on windows, and there might be case sensitivity issues happening. Though I’m not really sure how, I can use any name for the label and of course it works. here’s the test case I’m using, you get the same results with this? from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class A(Base): __tablename__ = 'a' id = Column(Integer, primary_key=True) e = create_engine("mysql+pymysql://scott:tiger@localhost/test", echo=True) Base.metadata.drop_all(e) Base.metadata.create_all(e) sess = Session(e) sess.add_all([A(), A(), A()]) print(sess.query(A.id.label('id')).all()) print(sess.query(A.id.label('foobar')).all()) signature.asc Description: Message signed with OpenPGP using GPGMail
[sqlalchemy] Could not locate column in row for column
Hello sqlalchemy team. im a new user to the alchemy, and doing the tutorial on ur site. ran ur tutorial on adding information to databases and querying against a virtual db (sqlite in memory) after i thought i got that, i tried testing against a real db - mysql db. im using the driver of pymysql version 0.4 (i know its kinda old, but when was using newer version i had other bugs, not related to this topic). my code is as follows: import sqlalchemy from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from CpuTable import CpuTable def read_from_DB(): engine = create_engine('mysql+pymysql://***@***/test', echo=True) Session = sessionmaker(bind=engine) session=Session() #insert = CpuTable(id='15',name= 'igal') #session.add(insert) #session.commit() print() print(str(session.query(CpuTable.id.label('id')).all())) for cpu_id,cpu_name in session.query(CpuTable).all(): print(cpu_id,cpu_name) my stack trace is as follows: C:\Python33\python.exe J:/working_dir/TLM/lib/DB_Wrapper/Lab_DB/DB_Reader.py 2014-02-12 11:23:57,193 INFO sqlalchemy.engine.base.Engine SELECT DATABASE() 2014-02-12 11:23:57,193 INFO sqlalchemy.engine.base.Engine () 2014-02-12 11:23:57,196 INFO sqlalchemy.engine.base.Engine SHOW VARIABLES LIKE 'character_set%%' 2014-02-12 11:23:57,196 INFO sqlalchemy.engine.base.Engine () 2014-02-12 11:23:57,198 INFO sqlalchemy.engine.base.Engine SHOW VARIABLES LIKE 'sql_mode' 2014-02-12 11:23:57,198 INFO sqlalchemy.engine.base.Engine () 2014-02-12 11:23:57,199 INFO sqlalchemy.engine.base.Engine BEGIN (implicit) 2014-02-12 11:23:57,199 INFO sqlalchemy.engine.base.Engine SELECT cpu.id AS id FROM cpu 2014-02-12 11:23:57,199 INFO sqlalchemy.engine.base.Engine () Traceback (most recent call last): File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", line 69, in __getitem__ KeyError: During handling of the above exception, another exception occurred: Traceback (most recent call last): File "J:/working_dir/TLM/lib/DB_Wrapper/Lab_DB/DB_Reader.py", line 39, in read_from_DB() File "J:/working_dir/TLM/lib/DB_Wrapper/Lab_DB/DB_Reader.py", line 26, in read_from_DB print(str(session.query(CpuTable.id.label('id')).all())) File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", line 2264, in all File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", line 75, in instances File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", line 75, in File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\loading.py", line 74, in File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\orm\query.py", line 3440, in proc File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", line 71, in __getitem__ File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0-py3.3.egg\sqlalchemy\engine\result.py", line 317, in _key_fallback sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for column 'cpu.id'" when debugging this issue, i managed to find out that i do get the result from the db, only if the quesry was "select table.id" it returns as "table_id". (i talked with some friends using this, and they confirmed it happens on their hand as well, only their sqlalchemy wrapper knows how to handle with this, while mine throws this error) . the commented out insert lines are to check i had connection to the db, and also to check it inserts the data, and it does, the query part is the problem. also while testing this against the sqlite in memory db it does work. hence my question is what can be the problem when working against mysql db with pymysql driver? tried searching the web for 1 day for similar problems couldnt find even 1. my sqlalchemy version was 0.9.1 and i downgraded it to 0.9 and still the problem persists. thx -- 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/groups/opt_out.