Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3750478
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T08:56:27+00:00 2026-05-19T08:56:27+00:00

Just diving into pylons here, and am trying to get my head around the

  • 0

Just diving into pylons here, and am trying to get my head around the basics of SQLALchemy. I have figured out how to load a record by id:

user_q = session.query(model.User)
user = user_q.get(user_id)

But how do I query by a specific field (i.e. username)? I assume there is a quick way to do it with the model rather than hand-building the query. I think it has something with the add_column() function on the query object, but I can’t quite figure out how to use it. I’ve been trying stuff like this, but obviously it doesn’t work:

user_q = meta.Session.query(model.User).add_column('username'=user_name)
user = user_q.get()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T08:56:27+00:00Added an answer on May 19, 2026 at 8:56 am

    I believe you want something like this:

    user = meta.Session.query(model.User).filter_by(name=user_name).first()
    

    Which is short for this:

    user = meta.Session.query(model.User).filter(model.User.name=user_name).first()
    

    Here’s more documentation

    If you change first() into one() it will raise an exception if there isn’t a user (if you want to assert one exists).

    I highly suggest reading through both Object Relational Tutorial as well as the and the SQL Expression Language Tutorial.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just diving into Procs, blocks, and lambdas. I'm noodling around trying different things,
I'm just diving into the exciting world of facebook app creation, but have already
I'm just diving into Datamapper (and Sinatra) and have a question about associations. Below
I just started diving into vi and so far learned only basic moving around/editing
I'm diving into iOS development and I just found out about the Static Analyzer
I'm diving into EMF now, and have encountered the following problem: I'm trying to
I'm just diving into ActiveRecord and have not been able to find an answer
I just started diving into Go recently and I have one major point of
I've just begun diving into data warehousing and I have one question that I
Before diving into Wordpress just wanted to see if it is possible to have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.