sqlalchemy-citext

A sqlalchemy plugin that allows postgres use of CITEXT
Download

sqlalchemy-citext Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Mahmoud Abdelkader
  • Publisher web site:
  • https://github.com/mahmoudimus/

sqlalchemy-citext Tags


sqlalchemy-citext Description

sqlalchemy-citext is a SQLAlchemy plugin that allows postgres use of CITEXT.Usage```pythonfrom sqlalchemy import create_engine, MetaData, Integerfrom sqlalchemy.schema import Column, Tableimport sqlalchemy.orm as ormengine = create_engine('postgresql://localhost/test_db')meta = MetaData()test_table = Table('test', meta, Column('id', Integer(), primary_key=True), Column('txt', CIText()))conn = engine.connect()meta.bind = connmeta.drop_all()meta.create_all()class TestObj(object): def __init__(self, id_, txt): self.id = id_ self.txt = txt def __repr__(self): return "TestObj(%r, %r)" % (self.id, self.txt)orm.mapper(TestObj, test_table)Session = orm.sessionmaker(bind=engine)ses = Session()to = TestObj(1, txt='FooFighter')ses.add(to)ses.commit()row = ses.query(TestObj).filter(TestObj.txt == 'foofighter').all()assert len(row) == 1print rowses.close()```Product's homepage


sqlalchemy-citext Related Software