X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FPostgreSQL.py;h=5c12257e7c36dc54e800adba381a7b7aeb87444b;hb=bb508a5a3a28e71913beaa983c4e02177afc7ace;hp=597077afe1b7773e304f436b59c72ca25c10ceee;hpb=b74c5345bb5c74c64beeeacad2e9aaba3220455a;p=plcapi.git diff --git a/PLC/PostgreSQL.py b/PLC/PostgreSQL.py index 597077a..5c12257 100644 --- 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" % \