git://git.onelab.eu
/
plcapi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
749e382
)
merge from trunk. changes how we obtain serial primary keys
author
Tony Mack
<tmack@cs.princeton.edu>
Thu, 31 Jul 2008 18:10:11 +0000
(18:10 +0000)
committer
Tony Mack
<tmack@cs.princeton.edu>
Thu, 31 Jul 2008 18:10:11 +0000
(18:10 +0000)
PLC/PostgreSQL.py
patch
|
blob
|
history
diff --git
a/PLC/PostgreSQL.py
b/PLC/PostgreSQL.py
index
4e05639
..
22c2b63
100644
(file)
--- a/
PLC/PostgreSQL.py
+++ b/
PLC/PostgreSQL.py
@@
-134,6
+134,15
@@
class PostgreSQL:
cursor.close()
return self.rowcount
+ def next_id(self, table_name, primary_key):
+ sequence = "%(table_name)s_%(primary_key)s_seq" % locals()
+ sql = "SELECT nextval('%(sequence)s')" % locals()
+ rows = self.selectall(sql, hashref = False)
+ if rows:
+ return rows[0][0]
+
+ return None
+
def last_insert_id(self, table_name, primary_key):
if isinstance(self.lastrowid, int):
sql = "SELECT %s FROM %s WHERE oid = %d" % \