{"id":22400,"library":"sqlalchemy-citext","title":"SQLAlchemy CIText","description":"A SQLAlchemy plugin that provides CITEXT (case-insensitive text) support for PostgreSQL. The latest version is 1.8.0, with infrequent releases as needed.","status":"active","version":"1.8.0","language":"python","source_language":"en","source_url":"https://github.com/mahmoudimus/sqlalchemy-citext","tags":["sqlalchemy","postgres","citext","case-insensitive"],"install":[{"cmd":"pip install sqlalchemy-citext","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for database interaction","package":"sqlalchemy","optional":false},{"reason":"PostgreSQL driver","package":"psycopg2-binary","optional":true}],"imports":[{"note":"Correct import path","wrong":"","symbol":"CIText","correct":"from sqlalchemy_citext import CIText"},{"note":"Correct import for the comparator","wrong":"","symbol":"CITextComparator","correct":"from sqlalchemy_citext.types import CITextComparator"}],"quickstart":{"code":"from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy_citext import CIText\n\nBase = declarative_base()\n\nclass User(Base):\n    __tablename__ = 'users'\n    id = Column(Integer, primary_key=True)\n    name = Column(CIText)\n\nengine = create_engine('postgresql://user:pass@localhost/db')\nBase.metadata.create_all(engine)\n\n# Insert and query case-insensitively\nfrom sqlalchemy.orm import sessionmaker\nSession = sessionmaker(bind=engine)\nsession = Session()\nsession.add(User(name='Alice'))\nsession.commit()\nuser = session.query(User).filter(User.name == 'alice').first()  # works\nprint(user.name)  # Alice","lang":"python","description":"Example using CIText with SQLAlchemy ORM."},"warnings":[{"fix":"Grant CREATE ON SCHEMA public TO your_user; or create the type manually before using CIText.","message":"CIText creates a custom PostgreSQL type 'citext' on first use. Ensure the user has permissions to CREATE TYPE in the public schema.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Use `from sqlalchemy_citext import CIText`.","message":"The import `from sqlalchemy_citext import CIText` is preferred. Older code may use `from citext import CIText` which is deprecated.","severity":"deprecated","affected_versions":"<1.0"},{"fix":"Ensure your database URL points to a PostgreSQL instance.","message":"CIText only works with PostgreSQL. Attempting to use it with other databases (like SQLite) will cause errors.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Reinstall the package: pip install --upgrade sqlalchemy-citext. Ensure you use the correct import: from sqlalchemy_citext import CIText.","cause":"Incorrect installation or missing extension","error":"ImportError: cannot import name 'CIText' from 'sqlalchemy_citext'"},{"fix":"Run: from sqlalchemy_citext import CIText; CIText().create_type(engine). Or let SQLAlchemy create all tables.","cause":"CIText type not created in the database","error":"ProgrammingError: type \"citext\" does not exist"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}