Bonsoir,
Peut-on, dans un script utiliser RunSql pour executer une requete INSERT INTO?
Dans le script ci-dessous et en utilisant APSO, j’ obtiens l’ erreur suivante:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "<console>", line 6, in ouvrirTable
File "/opt/libreoffice24.8/program/scriptforge.py", line 1849, in RunSql
return self.ExecMethod(self.vbMethod, 'RunSql', sqlcommand, directsql)
File "/opt/libreoffice24.8/program/scriptforge.py", line 621, in ExecMethod
return self.EXEC(self.objectreference, flags, methodname, *args)
File "/opt/libreoffice24.8/program/scriptforge.py", line 353, in InvokeBasicService
raise RuntimeError("The execution of the method '" + method + "' failed. Execution stops.")
RuntimeError: The execution of the method 'RunSql' failed. Execution stops
Au départ, je pensai que la requete présentée un defaut de syntaxe mais le message oriente plus sur RunSql
Script en cause:
#! /user/bin/env python3
from scriptforge import CreateScriptService
import uno
def ouvrirTable(event = True):
ui = CreateScriptService('ui')
db = ui.GetDocument('/mnt/El_Casot/Yvon/Informatique/LibreOffice/Base_Test.odb')
base = db.GetDatabase()
#base.openTable('T_Departement')
#Requête à executer
rqt = 'INSERT INTO "T_Departement" ("Numero", "Departement") VALUES(1, "Ain");'
try:
base.RunSql(rqt, directsql=True)
except Exception as e:
print(f"Une erreur est survenue : {e}")
ouvrirTable()
Merci de vos réponses.
Cordialement