On Mon, 7 Jan 201U9, Mike Bayer wrote:

Postgresql has ENUM within CREATE TYPE:
https://www.postgresql.org/docs/9.1/datatype-enum.html

Mike,

  Thank you. I hadn't looked at the postgres docs for it.

I'm not sure if this is a "DOMAIN" behind the scenes or what.

  Postgres supports the SQL DOMAIN. Whether enum is equivalent is yet to be
determined. :-)

This SQL syntax is directly supported with the PG ENUM type:
https://docs.sqlalchemy.org/en/latest/dialects/postgresql.html?highlight=enum#enum-types
which is also available from the generic enum type:
https://docs.sqlalchemy.org/en/latest/core/type_basics.html#sqlalchemy.types.Enum,
as long as native_enum=True on that object.

Enum is pretty popular so it should work well.

  Thanks for the URLs. I glanced at the SA constraint doc's section on enum
but have not yet carefully read it.

  I'm using the domain because the same column check constraint applies to
two tables in this application so it makes sense to write it once and have
it applied everywhere there's a state_code column.

Best regards,

Rich

--
SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to