Skip to main content

A sqlalchemy plugin that allows postgres use of CITEXT.

Project description

# sqlalchemy-citext

Creates a SQLAlchemy user defined type to understand
[PostgreSQL's CIText](

## Installation

This requires some kind of PostgreSQL compatible db-api driver already
installed in order to work.

Make sure you have something like `psycopg2` already installed.

pip install sqlalchemy-citext

## Usage

from sqlalchemy import create_engine, MetaData, Integer
from sqlalchemy.schema import Column, Table
import sqlalchemy.orm as orm

engine = 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 = conn

class TestObj(object):
def __init__(self, id_, txt): = id_
self.txt = txt

def __repr__(self):
return "TestObj(%r, %r)" % (, self.txt)

orm.mapper(TestObj, test_table)
Session = orm.sessionmaker(bind=engine)
ses = Session()

to = TestObj(1, txt='FooFighter')
row = ses.query(TestObj).filter(TestObj.txt == 'foofighter').all()
assert len(row) == 1
print row

## License

`sqlalchemy-citext` is an MIT/BSD dual-Licensed library.

## Contribute

- Check for open issues or open a fresh issue to start a discussion around a
feature idea or a bug.
- Fork the repository on GitHub to start making your changes to the master
branch (or branch off of it).
- Write a test which shows that the bug was fixed or that the feature
works as expected.
- Send a pull request and bug the maintainer until it gets merged and
- Make sure to add yourself to the author's file in `` and the
`Contributors` section below :)

## Contributors

- [@mahmoudimus](
- [@vad](
- [@dstufft](
- [@brmzkw](

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
sqlalchemy-citext-1.3-0.tar.gz (3.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page