python - Sqlalchemy from_statement() cannot locate column -
I am following the sqlalchemy tutorial
However, instead of using a SQLite backend , I'm using MySQL The problem is that when I try to perform a textual MySQL statement to select a column from the user table, such as
select name from users;
This will fail
NoSuchColumnError: "Column can not be found in column for column 'users.id'"
< / Pre>While selecting from a
users
are working fine.
class user (base): __tablename__ = 'users' id = column (integer, primary_key = true)
name = column (string (50)) full name = column (String (50)) password = column (string (50)) def __repr __ (self): return "& lt; user (name = '% s', fullname = '% s', password = '% s') The session is defined as session (as.name, self.fullname, self.password)
:
session = Session maker (bind = engine) session = session ()
and I am trying to do
session.query (using ) .from_statement (Select from users')
By the way, this statement works fine when running on MySQL client. Am I missing something or is this a bug?
session .query (user) syntax .from_statement ( 'Select Name From Users')
is incorrect. It should be
session.query ('name'). From_statement (Select names from users))
Call to call should be in the list of columns ().
Comments
Post a Comment