Using "IF NOT EXISTS" would not solve this problem in a high concurrency scenario.
There would still be a race condition within the Postgres internal functions. This is because of how Postgres checks for existing tables and creates new ones with its internal bookkeeping. It's explained in the link that Mike shared above. Have you tried using savepoints? SqlAlchemy handles them within the "nested transaction" concept. I'm not sure how Postgres would handle race conditions of table creation within a savepoint, but it might get you past this issue. -- 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.