Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract a weekday() from an SQLAlchemy InstrumentedAttribute (Column type is datetime)

I have an SQLAlchemy DB column which is of type datetime:

type(<my_object>) --> sqlalchemy.orm.attributes.InstrumentedAttribute

How do I reach the actual date in order to filter the DB by weekday() ?

like image 570
Omer H Avatar asked Aug 05 '15 19:08

Omer H


1 Answers

I got it: from sqlalchemy import func (func.extract(<my_object>, 'dow') == some_day)

dow stands for 'day of week' The extract is an SQLAlchemy function allowing the extraction of any field from the column object.

like image 190
Omer H Avatar answered Sep 30 '22 21:09

Omer H