Macros/Base/py002

From The Document Foundation Wiki
< Macros‎ | Base
Jump to navigation Jump to search
Other languages:
English

Description

Execute update in current database

Python code

 1import uno
 2
 3def 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