sql-domain

How to represent a custom PostgreSQL domain in SQLAlchemy?

十年热恋 提交于 2019-11-30 09:06:57
I'm beginning to incorporate Alembic into my project which already uses SQLAlchemy table definitions. At present my DB schema is managed external to my application, and I want to bring the entire schema into my table definitions file. In PostgreSQL I use a custom domain for storing email addresses. The PostgreSQL DDL is: CREATE DOMAIN email_address TEXT CHECK (value ~ '.+@.+') How do I represent the creation of this domain, and the usage of it as a column data type, in SQLAlchemy? This likely far from a working solution, but I think the best way to do this would be subclass sqlalchemy.schema.

How to represent a custom PostgreSQL domain in SQLAlchemy?

这一生的挚爱 提交于 2019-11-29 14:22:30
问题 I'm beginning to incorporate Alembic into my project which already uses SQLAlchemy table definitions. At present my DB schema is managed external to my application, and I want to bring the entire schema into my table definitions file. In PostgreSQL I use a custom domain for storing email addresses. The PostgreSQL DDL is: CREATE DOMAIN email_address TEXT CHECK (value ~ '.+@.+') How do I represent the creation of this domain, and the usage of it as a column data type, in SQLAlchemy? 回答1: This