SQLAlchemy for Python, 'Query' object has no attribute 'fetchone' -


i'm working on database-centric project fellow programmer. have following code retrieving information our database:

# create connection database engine = create_engine(url(**database)) session = sessionmaker(bind=engine) session = session() # construct query query = session.query(mediatext.line_number, mediatext.start_time_stamp, mediatext.end_time_stamp).\     filter(mediatext.oclc_id == oclcid)  # info first line snapshot line_to_snapshot = query.fetchone() 

when try run code, following error:

attributeerror: 'query' object has no attribute 'fetchone'

what's confusing partner can run code fine. we're both running python 3.4 , have version 1.0.9 of sqlalchemy library on our systems. know going wrong here?

from sqlalchemy's query api , know (python 2.7 , sqlalchemy 1.0.4) fetchone not part of query api, although one is.

how changing to:

line_to_snapshot = query.one() , see if works?


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -