Mercurial > p > roundup > code
comparison roundup/backends/back_postgresql.py @ 3687:ff9f4ca42454
Postgres backend allows transaction collisions to be ignored when...
...committing clenup in the sessions database
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 29 Aug 2006 04:20:50 +0000 |
| parents | 4d9adb8bc3b1 |
| children | 50add98cbbac |
comparison
equal
deleted
inserted
replaced
| 3686:1671d1e39b1a | 3687:ff9f4ca42454 |
|---|---|
| 1 #$Id: back_postgresql.py,v 1.33 2006-08-23 12:57:10 schlatterbeck Exp $ | 1 #$Id: back_postgresql.py,v 1.34 2006-08-29 04:20:50 richard Exp $ |
| 2 # | 2 # |
| 3 # Copyright (c) 2003 Martynas Sklyzmantas, Andrey Lebedev <andrey@micro.lt> | 3 # Copyright (c) 2003 Martynas Sklyzmantas, Andrey Lebedev <andrey@micro.lt> |
| 4 # | 4 # |
| 5 # This module is free software, and you may redistribute it and/or modify | 5 # This module is free software, and you may redistribute it and/or modify |
| 6 # under the same terms as Python, so long as this copyright message and | 6 # under the same terms as Python, so long as this copyright message and |
| 179 self.sql('ALTER TABLE _%s add __actor VARCHAR(255)'%name) | 179 self.sql('ALTER TABLE _%s add __actor VARCHAR(255)'%name) |
| 180 | 180 |
| 181 def __repr__(self): | 181 def __repr__(self): |
| 182 return '<roundpsycopgsql 0x%x>' % id(self) | 182 return '<roundpsycopgsql 0x%x>' % id(self) |
| 183 | 183 |
| 184 def sql_commit(self, fail_ok=False): | |
| 185 ''' Actually commit to the database. | |
| 186 ''' | |
| 187 logging.getLogger('hyperdb').info('commit') | |
| 188 | |
| 189 try: | |
| 190 self.conn.commit() | |
| 191 except psycopg.ProgrammingError, message: | |
| 192 # we've been instructed that this commit is allowed to fail | |
| 193 if fail_ok and str(message).endswith('could not serialize ' | |
| 194 'access due to concurrent update'): | |
| 195 logging.getLogger('hyperdb').info('commit FAILED, but fail_ok') | |
| 196 else: | |
| 197 raise | |
| 198 | |
| 199 # open a new cursor for subsequent work | |
| 200 self.cursor = self.conn.cursor() | |
| 201 | |
| 184 def sql_stringquote(self, value): | 202 def sql_stringquote(self, value): |
| 185 ''' psycopg.QuotedString returns a "buffer" object with the | 203 ''' psycopg.QuotedString returns a "buffer" object with the |
| 186 single-quotes around it... ''' | 204 single-quotes around it... ''' |
| 187 return str(psycopg.QuotedString(str(value)))[1:-1] | 205 return str(psycopg.QuotedString(str(value)))[1:-1] |
| 188 | 206 |
