insertions via notesdb dans tables sans ids
This commit is contained in:
parent
e1dad774be
commit
357b6f1a7f
@ -82,7 +82,7 @@ def SimpleDictFetch(query, args, cursor=None):
|
|||||||
return cursor.dictfetchall()
|
return cursor.dictfetchall()
|
||||||
|
|
||||||
|
|
||||||
def DBInsertDict(cnx, table, vals, commit=0, convert_empty_to_nulls=1):
|
def DBInsertDict(cnx, table, vals, commit=0, convert_empty_to_nulls=1, return_id=True):
|
||||||
"""insert into table values in dict 'vals'
|
"""insert into table values in dict 'vals'
|
||||||
Return: id de l'object créé
|
Return: id de l'object créé
|
||||||
"""
|
"""
|
||||||
@ -104,8 +104,11 @@ def DBInsertDict(cnx, table, vals, commit=0, convert_empty_to_nulls=1):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
cursor.execute("insert into %s default values" % table)
|
cursor.execute("insert into %s default values" % table)
|
||||||
|
if return_id:
|
||||||
cursor.execute(f"SELECT CURRVAL('{table}_id_seq')") # id créé
|
cursor.execute(f"SELECT CURRVAL('{table}_id_seq')") # id créé
|
||||||
oid = cursor.fetchone()[0]
|
oid = cursor.fetchone()[0]
|
||||||
|
else:
|
||||||
|
oid = None
|
||||||
except:
|
except:
|
||||||
log("DBInsertDict: EXCEPTION !")
|
log("DBInsertDict: EXCEPTION !")
|
||||||
log("DBInsertDict: table=%s, vals=%s" % (str(table), str(vals)))
|
log("DBInsertDict: table=%s, vals=%s" % (str(table), str(vals)))
|
||||||
@ -305,7 +308,13 @@ class EditableTable(object):
|
|||||||
if title in self.input_formators:
|
if title in self.input_formators:
|
||||||
vals[title] = self.input_formators[title](vals[title])
|
vals[title] = self.input_formators[title](vals[title])
|
||||||
# insert
|
# insert
|
||||||
new_id = DBInsertDict(cnx, self.table_name, vals, commit=True)
|
new_id = DBInsertDict(
|
||||||
|
cnx,
|
||||||
|
self.table_name,
|
||||||
|
vals,
|
||||||
|
commit=True,
|
||||||
|
return_id=(self.id_name is not None),
|
||||||
|
)
|
||||||
return new_id
|
return new_id
|
||||||
|
|
||||||
def delete(self, cnx, oid, commit=True):
|
def delete(self, cnx, oid, commit=True):
|
||||||
|
Loading…
Reference in New Issue
Block a user