platypush/plugins/db/__init__.py
def update(self, table, records, key_columns, engine=None, *args, **kwargs):
        """
        Updates records on a table.

        :param table: Table name
        :type table: str
        :param records: Records to be updated (as a list of hashes)
        :type records: list
        :param key_columns: Names of the key columns, used in the WHERE condition
        :type key_columns: list
        :param engine: Engine to be used (default: default class engine)
        :type engine: str
        :param args: Extra arguments that will be passed to ``sqlalchemy.create_engine`` (see https://docs.sqlalchemy.org/en/latest/core/engines.html)
        :param kwargs: Extra kwargs that will be passed to ``sqlalchemy.create_engine`` (seehttps:///docs.sqlalchemy.org/en/latest/core/engines.html)

        Example:

            Request::

                {
                    "type": "request",
                    "target": "your_host",
                    "action": "db.update",
                    "args": {
                        "table": "table",
                        "engine": "sqlite:///:memory:",
                        "key_columns": ["id"],
                        "records": [
                            {
                                "id": 1,
                                "name": foo
                            },

                            {
                                "id": 2,
                                "name": bar
                            }
                        ]
                    }
                }
        """

        engine = self._get_engine(engine, *args, **kwargs)

        for record in records:
            table, engine = self._get_table(table, engine=engine, *args, **kwargs)
            key = { k:v for (k,v) in record.items() if k in key_columns }
            values = { k:v for (k,v) in record.items() if k not in key_columns }

            update = table.update()

            for (k,v) in key.items():
                update = update.where(self._build_condition(table, k, v))

            update = update.values(**values)
            engine.execute(update)

        Updates records on a table.

        :param table: Table name
        :type table: str
        :param records: Records to be updated (as a list of hashes)
        :type records: list
        :param key_columns: Names of the key columns, used in the WHERE condition
        :type key_columns: list
        :param engine: Engine to be used (default: default class engine)
        :type engine: str
        :param args: Extra arguments that will be passed to ``sqlalchemy.create_engine`` (see https://docs.sqlalchemy.org/en/latest/core/engines.html)
        :param kwargs: Extra kwargs that will be passed to ``sqlalchemy.create_engine`` (seehttps:///docs.sqlalchemy.org/en/latest/core/engines.html)

        Example:

            Request::

                {
                    "type": "request",
                    "target": "your_host",
                    "action": "db.update",
                    "args": {
                        "table": "table",
                        "engine": "sqlite:///:memory:",
                        "key_columns": ["id"],
                        "records": [
                            {
                                "id": 1,
                                "name": foo
                            },

                            {
                                "id": 2,
                                "name": bar
                            }
                        ]
                    }
                }
        
Updates records on a table.
Updates records on a table .
def update(self, table, records, key_columns, engine=None, *args, **kwargs):
        engine = self._get_engine(engine, *args, **kwargs)
        for record in records:
            table, engine = self._get_table(table, engine=engine, *args, **kwargs)
            key = { k:v for (k,v) in record.items() if k in key_columns }
            values = { k:v for (k,v) in record.items() if k not in key_columns }
            update = table.update()
            for (k,v) in key.items():
                update = update.where(self._build_condition(table, k, v))
            update = update.values(**values)
            engine.execute(update)
def update ( self , table , records , key_columns , engine = None , * args , ** kwargs ) : engine = self . _get_engine ( engine , * args , ** kwargs ) for record in records : table , engine = self . _get_table ( table , engine = engine , * args , ** kwargs ) key = { k : v for ( k , v ) in record . items ( ) if k in key_columns } values = { k : v for ( k , v ) in record . items ( ) if k not in key_columns } update = table . update ( ) for ( k , v ) in key . items ( ) : update = update . where ( self . _build_condition ( table , k , v ) ) update = update . values ( ** values ) engine . execute ( update )
Updates records on a table.
Updates records on a table .
"""
        Updates records on a table.

        :param table: Table name
        :type table: str
        :param records: Records to be updated (as a list of hashes)
        :type records: list
        :param key_columns: Names of the key columns, used in the WHERE condition
        :type key_columns: list
        :param engine: Engine to be used (default: default class engine)
        :type engine: str
        :param args: Extra arguments that will be passed to ``sqlalchemy.create_engine`` (see https://docs.sqlalchemy.org/en/latest/core/engines.html)
        :param kwargs: Extra kwargs that will be passed to ``sqlalchemy.create_engine`` (seehttps:///docs.sqlalchemy.org/en/latest/core/engines.html)

        Example:

            Request::

                {
                    "type": "request",
                    "target": "your_host",
                    "action": "db.update",
                    "args": {
                        "table": "table",
                        "engine": "sqlite:///:memory:",
                        "key_columns": ["id"],
                        "records": [
                            {
                                "id": 1,
                                "name": foo
                            },

                            {
                                "id": 2,
                                "name": bar
                            }
                        ]
                    }
                }
        """
self
table
None
records
Records to be updated (as a list of hashes)
Records to be updated ( as a list of hashes )
key_columns
Names of the key columns, used in the WHERE condition
Names of the key columns used in the WHERE condition
engine
Engine to be used (default: default class engine)
Engine to be used ( default : default class engine )
args
Extra arguments that will be passed to ``sqlalchemy.create_engine``
Extra arguments that will be passed to ` ` sqlalchemy . create_engine ` `
kwargs
Extra kwargs that will be passed to ``sqlalchemy.create_engine``
Example.






Extra kwargs that will be passed to ` ` sqlalchemy . create_engine ` ` Example .