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 7880747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:13:05+00:00 2026-06-03T04:13:05+00:00

when i have a table in MySQL: create table t ( id integer primary

  • 0

when i have a table in MySQL:

create table t
(
    id integer primary key,
    time datetime not null,
    value integer not null
)

and an mapping class:

class T(Base):
    __tablename__ = 't'

    id = Column(INTEGER, primary_key=True, nullable=False, unique=True)
    time = Column(DATETIME, nullable=False)
    value = Column(INTEGER, nullable=False)

how can i select all values that have given month from this table using SQLAlchemy?
MySQL has the month function: select value from t where month(time) = 4
but SQLAlchemy has no month function.

  • 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-06-03T04:13:07+00:00Added an answer on June 3, 2026 at 4:13 am

    Without loading all Ts into the session, one can use Functions to filter non April objects straight-away:

    from sqlalchemy.sql import func
    qry = session.query(T).filter(func.MONTH(T.time) == 4)
    for t in qry:
        print t.value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sql: create table autori( id_autor integer primary key auto_increment, nume varchar(50) not null, prenume
Assume the following in MySQL: CREATE TABLE users ( id integer auto_increment primary key,
I have 2 tables in my mysql database: CREATE TABLE IF NOT EXISTS `RECIPES`
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
CREATE TABLE titlexplan( id INTEGER NOT NULL, title_id INTEGER NOT NULL , plan_id INTEGER
I have the following table: CREATE TABLE `events` ( `evt_id` int(11) NOT NULL AUTO_INCREMENT,
I have to create a script that takes a mySQL table, and exports it
Lets say I have the following MySQL structure: CREATE TABLE `domains` ( `id` INT(10)
I have a huge table from one mysql db, I want to create a
i have a table in mysql db ( created_date). It stores timestamps (INT value).

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.