Macros/Base/py002

    From The Document Foundation Wiki
    < Macros‎ | Base
    Other languages:

    Description

    Execute update in current database

    Python code

    import uno
    
    def main():
        doc = XSCRIPTCONTEXT.getDocument()
        conn = doc.DataSource.getConnection('', '')
    
        sql = 'UPDATE "contactos" SET "numbers"=TRIM("numbers")'
        cursor = conn.prepareStatement(sql)
        result = cursor.executeUpdate()
        doc.store()
        return