Mike Bayer <[email protected]> writes:
> Can you show me the model and some sample data ? Is this the JSONB
> datatype ?
Sure, here it is:
import datetime
from sqlalchemy import create_engine, select, Table, Column, Integer,
UnicodeText, MetaData
import sqlalchemy.dialects.postgresql as sapg
metadata = MetaData()
users = Table('users', metadata,
Column('id', Integer(), primary_key=True),
Column('name', UnicodeText()),
Column('active', sapg.DATERANGE()),
)
e = create_engine('postgresql://localhost/test')
metadata.create_all(e)
i = users.insert().values(name='myself', active='[2016-10-21,2020-10-22)')
e.execute(i)
q = select([users.c.id]) \
.where(users.c.name == 'myself') \
.where(users.c.active.contains(datetime.date.today()))
print(e.execute(q).fetchall())
This works as is with psycopg2 (maybe it was not clear that I was suggesting
an enhancement, not a fix :-).
ciao, lele.
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
[email protected] | -- Fortunato Depero, 1929.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.