From: <no...@so...> - 2002-10-21 02:31:06
|
Bugs item #611979, was opened at 2002-09-20 01:11 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116528&aid=611979&group_id=16528 Category: None Group: None Status: Open Resolution: Postponed Priority: 2 Submitted By: Nobody/Anonymous (nobody) Assigned to: Billy G. Allie (ballie01) Summary: CREATE DATABASE impossible? Initial Comment: It appears that the current code-base makes a create-database call impossible. Basically, the call can't happen within a transaction, so the default operation of wrapping everything in a transaction prevents the operation from working. I'm new to the project, but this would seem to be a minimal workaround: #378 re_CREATEDB = re.compile('[\s]*CREATE[\s]+DATABASE[\s]', re.I) #2518 _badQuery = re_CREATEDB.search(query) or ( (self.conn.version < 70100) and \ (re_DRT.search(query) or re_DRI.search(query) ) ) However, that doesn't address any other potential calls that need a non-transactional framework. Not sure how you'd want to do this in the general case (probably another method would be required). Enjoy, and thanks for the module, Mike ---------------------------------------------------------------------- >Comment By: Billy G. Allie (ballie01) Date: 2002-10-20 22:31 Message: Logged In: YES user_id=8500 At least the re_DRT and re_DRI checks. These are only needed for PostgreSQL versions less then 7.1, so they can definitely go in pyPgSQL 3.0. They can go in future versions of 2.x if we decide to drop support for versions of PostgreSQL erlier than 7.1. It would sure simplify the logic of that section of code :-) ---------------------------------------------------------------------- Comment By: Gerhard Häring (ghaering) Date: 2002-10-20 17:26 Message: Logged In: YES user_id=163326 I'd say keep it as it is for now, mainly because I don't feel like implementing this and testing it with PostgreSQL 7.0 through 7.3 for the next release. Billy, your suggestion would be fine with me. Does this mean we could then remove the existing checks for DDL statements and just add an according note to the docs? ---------------------------------------------------------------------- Comment By: Billy G. Allie (ballie01) Date: 2002-10-18 20:22 Message: Logged In: YES user_id=8500 With later versions of PostgreSQL, the number of things that have to be performed outside of a transaction has decreased. I would think that setting autocommit to 1 on the connection would be an acceptable solution for thoses operations that have to be outside of a transaction.. Your thoughts on this? ---------------------------------------------------------------------- Comment By: Gerhard Häring (ghaering) Date: 2002-09-20 01:30 Message: Logged In: YES user_id=163326 I'm not entirely sure what to do about this. You can (temporarily) set autocommit=1 to work around this: from pyPgSQL import PgSQL con = PgSQL.connect() con.autocommit = 1 cursor = con.cursor() cursor.execute("create database foo") con.close() ---------------------------------------------------------------------- Comment By: Mike C. Fletcher (mcfletch) Date: 2002-09-20 01:12 Message: Logged In: YES user_id=34901 Sorry, this report was from me, just forgot to log in first. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116528&aid=611979&group_id=16528 |