title: SQLAlchemy How to obtain a response from Session query object?
body: <p>I've worked through the <a href="http://docs.sqlalchemy.org/en/latest/orm/tutorial.html" rel="nofollow noreferrer">SQLAlchemy ORM tutorial</a> and am now adapting it to my own database. I've run into an issue with the Postgres dialect where I am attempting to query the Session object, however I am not receiving a result. I am sure I missed something, and could use some direction in getting this to work, or at least what I should research. Thank you for your help.</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>import sqlalchemy
  from sqlalchemy import create_engine, ForeignKey, Column, INTEGER
  from sqlalchemy.ext.declarative import declarative_base
  from sqlalchemy.dialects.postgresql import TEXT, NUMERIC, TIMESTAMP
  from sqlalchemy.orm import sessionmaker
  
  # CONNECTING
  # create an instance of Engine, represents core interface to the db
  engine = create_engine('postgresql://user:pass@ip:port/db', echo=True)
  
  # DECLARE A MAPPING
  # instantiate the Declarative base class for a catalog of classes &amp; tables
  # relative to the base class.
  Base = declarative_base()
  
  # map a table to a class by inheriting base class via declarative_base
  class History_1m(Base):
      __tablename__ = 'history_1m'
  
      id = Column(INTEGER, primary_key=True, autoincrement=True)
      name = Column(TEXT)
      symbol = Column(TEXT)
      ask = Column(NUMERIC)
      bid = Column(NUMERIC)
  
  # CREATE A SCHEMA
  # using the engine, create our table via a method of the MetaData registry
  Base.metadata.create_all(engine)
  
  # CREATE AN INSTANCE OF MAPPED CLASS
  # instantiate an instance of the User class and generate attribute values
  symbol_data = History_1m()
  
  # CREATING A SESSION
  # define a Session class to talk with our db
  Session = sessionmaker(bind=engine)
  session = Session()
  # in case of no engine yet, Session = sessionmaker() is acceptable
  # to talk to the db you should use session = Session each time
  
  # query the Session to verify the instance is pending
  symbol = 'AAPL'
  recent_symbol = session.query(History_1m).filter_by(symbol=symbol).first()
  
  # print the contents of our_user, ed_user is our_user via identity map
  print('\n&gt; Do we have a symbol entry?\n', recent_symbol)
  for row in session.query(History_1m).order_by(History_1m.id):
      print(row.name, row.symbol, row.ask, row.bid)
  </code></pre>
  
  <p><strong>Traceback</strong></p>
  
  <pre><code>Microsoft Corporation MSFT 65.52 65.51
  Adobe Systems Incorporated ADBE 131.85 131.83
  Cytori Therapeutics Inc CYTX 1.04 1.03
  Whole Foods Market, Inc. WFM 35.58 35.57
  None None None None
  </code></pre>
  
  <p>Process finished with exit code 0</p>