action

GenericDBWrapper.action(sql: str, *params, **kwparams) → int[source]

Use action() as a simple alias method for running “action” queries which don’t return results, only affected row counts.

For example INSERT, UPDATE, CREATE etc. queries.

This method calls query() with fetch='no', saves the row count into a variable, closes the cursor, then returns the affected row count as an integer.

>>> db = GenericDBWrapper('SomeDB')
>>> rows_affected = db.action("DELETE FROM users WHERE first_name LIKE 'John%';")
>>> rows_affected
4
Parameters
  • sql (str) – An SQL query to execute on the current DB, as a string.

  • params – Extra arguments will be passed through to cursor.execute(sql, *params, **kwparams)

  • kwparams – Extra arguments will be passed through to cursor.execute(sql, *params, **kwparams)

Return int row_count

Number of rows affected