Skip to main content

Creates a SQLAlchemy user defined type to understand PostgreSQL’s CIText extension.

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

from citext import CIText


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
meta.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) == 1
print row
ses.close()

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 published.

  • Make sure to add yourself to the author’s file in setup.py and the Contributors section below :)

Contributors

Release files for sqlalchemy-citext 1.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlalchemy-citext 1.8.0
File Size Uploaded
sqlalchemy-citext-1.8.0.tar.gz 3.6 kB Details

Release files / sqlalchemy-citext-1.8.0.tar.gz

Download URL sqlalchemy-citext-1.8.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a1740e693a9a334e7c8f60ae731083fe75ce6c1605bb9ca6644a6f1f63b15b77
BLAKE2b-256 checksum
How to use checksums
1ac3404caceaffdf0dcfa822e8b068aebc4fef328bf85af42b6cd8fdd2b2555b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.8

Release history Release notifications | RSS feed

This release

1.8.0 This release

1 release file

1.7.0

1 release file

1.6.3

2 release files

1.6.2

2 release files

1.6-1

2 release files

1.5-0

2 release files

1.3-0

1 release file

1.2-0

1 release file

1.1-0

1 release file

1.0-2

1 release file

1.0-1

1 release file

1.0-0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page