Macros/Base/py002

From The Document Foundation Wiki
< Macros‎ | Base
Jump to: navigation, search

Template:TopMenu/en Template:Menu/en Template:Menu.Macros/en

Other languages:

Description

Execute update in current database

Python code

 1 import uno
 2 
 3 def main():
 4     doc = XSCRIPTCONTEXT.getDocument()
 5     conn = doc.DataSource.getConnection('', '')
 6 
 7     sql = 'UPDATE "contactos" SET "numbers"=TRIM("numbers")'
 8     cursor = conn.prepareStatement(sql)
 9     result = cursor.executeUpdate()
10     doc.store()
11     return