[sqlalchemy] Re: MetaBase.create_all broken on parallel execution
This happened to me as well. Happened after installing libsqlite3-dev. Fixed by running apt-get remove libsqlite3-dev . Best, David. On Thursday, 8 November 2012 10:19:06 UTC+3, Eugeny Klementev wrote: Hi all, I use sqlalchemy with postgresql backend. On script starting i use code to initialize all table: engine = create_engine(settings.database_engine) Base.metadata.create_all(engine) session = Session(bind = engine) And i run two instances of this script. One of instances broken with message: Traceback (most recent call last): File ./datadb.py, line 40, in module Base.metadata.create_all(engine) File /usr/lib/python2.7/dist-packages/sqlalchemy/schema.py, line 2515, in create_all tables=tables) File /usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py, line 2234, in _run_visitor conn._run_visitor(visitorcallable, element, **kwargs) File /usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py, line 1904, in _run_visitor **kwargs).traverse_single(element) File /usr/lib/python2.7/dist-packages/sqlalchemy/sql/visitors.py, line 86, in traverse_single return meth(obj, **kw) File /usr/lib/python2.7/dist-packages/sqlalchemy/engine/ddl.py, line 67, in visit_metadata self.traverse_single(table, create_ok=True) File /usr/lib/python2.7/dist-packages/sqlalchemy/sql/visitors.py, line 86, in traverse_single return meth(obj, **kw) File /usr/lib/python2.7/dist-packages/sqlalchemy/engine/ddl.py, line 86, in visit_table self.connection.execute(schema.CreateTable(table)) File /usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py, line 1405, in execute params) File /usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py, line 1496, in _execute_ddl compiled File /usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py, line 1646, in _execute_context context) File /usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py, line 1639, in _execute_context context) File /usr/lib/python2.7/dist-packages/sqlalchemy/engine/default.py, line 330, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.IntegrityError: (IntegrityError) duplicate key value violates unique constraint pg_type_typname_nsp_index DETAIL: Key (typname, typnamespace)=(datadb_datapoint_id_seq, 2200) already exists. '\nCREATE TABLE datadb_datapoint (\n\tid SERIAL NOT NULL, \n\tunit_id INTEGER NOT NULL, \n\ttimestamp INTEGER NOT NULL, \n\tvalue_type VARCHAR NOT NULL, \n\tvalue VARCHAR NOT NULL, \n\tPRIMARY KEY (id)\n)\n\n' {} I understand it is conflict of creation of tables from different instances at one time. I hope that sqlalchemy has any locking mechanism, but my investigations are failed. Anybody known solution of my problem? -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sqlalchemy] How to get server or dialect version or properties?
Hi, In Cubes I would like to optionally use the upcoming CREATE MATERIALIZED VIEW [1] feature in Postgres 9.3 (or any other database that supports it). There will be plain alternative CREATE TABLE for Postgres 9.3. [1] http://michael.otacoo.com/postgresql-2/postgres-9-3-feature-highlight-materialized-views/ Is there some correct way how I can determine version of the server or at least some list of properties from which I can determine existence of such functionality? What might be the downsides of using ProgrammingError exception handling? try: CREATE MATERIALIZED VIEW AS SELECT ... except ProgrammingError: CREATE TABLE AS SELECT ... Are there any other options that would not require additional configuration variable on user's side? Regards, Stefan -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sqlalchemy] Re: How to get server or dialect version or properties?
Stefan Urbanek stefan.urba...@gmail.com writes: Is there some correct way how I can determine version of the server or at least some list of properties from which I can determine existence of such functionality? I used something like the following: cursor.execute(SELECT version()) v = cursor.fetchone() m = re.match('PostgreSQL (\d+)\.(\d+)\.(\d+)', v[0]) if m is None: # Maybe a beta? m = re.match('PostgreSQL (\d+)\.(\d+)(beta\d+)', v[0]) assert m, uCould not determine postgres version pg_version = tuple([int(x) for x in m.group(1, 2)]) hth, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sqlalchemy] How to get server or dialect version or properties?
there should be engine.dialect.server_version_info available, once at least one connection has been made. On Apr 13, 2013, at 12:26 PM, Stefan Urbanek stefan.urba...@gmail.com wrote: Hi, In Cubes I would like to optionally use the upcoming CREATE MATERIALIZED VIEW [1] feature in Postgres 9.3 (or any other database that supports it). There will be plain alternative CREATE TABLE for Postgres 9.3. [1] http://michael.otacoo.com/postgresql-2/postgres-9-3-feature-highlight-materialized-views/ Is there some correct way how I can determine version of the server or at least some list of properties from which I can determine existence of such functionality? What might be the downsides of using ProgrammingError exception handling? try: CREATE MATERIALIZED VIEW AS SELECT ... except ProgrammingError: CREATE TABLE AS SELECT ... Are there any other options that would not require additional configuration variable on user's side? Regards, Stefan -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sqlalchemy] How to get server or dialect version or properties?
Thank you, this solves my problem. On Saturday, April 13, 2013 2:53:15 PM UTC-5, Michael Bayer wrote: there should be engine.dialect.server_version_info available, once at least one connection has been made. On Apr 13, 2013, at 12:26 PM, Stefan Urbanek stefan@gmail.comjavascript: wrote: Hi, In Cubes I would like to optionally use the upcoming CREATE MATERIALIZED VIEW [1] feature in Postgres 9.3 (or any other database that supports it). There will be plain alternative CREATE TABLE for Postgres 9.3. [1] http://michael.otacoo.com/postgresql-2/postgres-9-3-feature-highlight-materialized-views/ Is there some correct way how I can determine version of the server or at least some list of properties from which I can determine existence of such functionality? What might be the downsides of using ProgrammingError exception handling? try: CREATE MATERIALIZED VIEW AS SELECT ... except ProgrammingError: CREATE TABLE AS SELECT ... Are there any other options that would not require additional configuration variable on user's side? Regards, Stefan -- 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+...@googlegroups.com javascript:. To post to this group, send email to sqlal...@googlegroups.comjavascript: . Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.