you have a Postgresql ENUM type in there with a name that is already in use. However the ENUM should be doing a check for that enum ahead of time. the SQL log, which you can get with echo=‘debug', should illustrate it looking for the existing ENUM and that will indicate what it’s finding, perhaps this name is used in some other context and that’s the source of the conflict.
Options include: 1. When you use ENUM with PG, and the name is one that is used elsewhere, add in “create_type=False”. For this use case, make sure it is sqlalchemy.dialects.postgresql.ENUM and not sqlalchemy.Enum. 2. You can also create the ENUM up front conditionally using my_enum.create(checkfirst=True) which may shed some light on why it thinks that type exists already. 3. Otherwise, give this Enum a different name, so it’s something unique vs. the other enum or type that already exists. > On Nov 19, 2014, at 1:56 PM, kiwi <z...@ledgerx.com> wrote: > > Hello, > > I am using sqlalchemy 0.9.8 and postgres 9.3. > > `metadata.create_all(db_engine)` results in: > > sqlalchemy.exc.IntegrityError: (IntegrityError) duplicate key value violates > unique constraint "pg_type_typname_nsp_index" > DETAIL: Key (typname, typnamespace)=(SOME_ENUM, 2200) already exists. > > Here's the traceback: http://pastebin.com/q97dYRgj > > What am I doing wrong? > > Thanks! > > -- > 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 > <mailto:sqlalchemy+unsubscr...@googlegroups.com>. > To post to this group, send email to sqlalchemy@googlegroups.com > <mailto:sqlalchemy@googlegroups.com>. > Visit this group at http://groups.google.com/group/sqlalchemy > <http://groups.google.com/group/sqlalchemy>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- 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 http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.