pgcontents/query.py
def reencrypt_row_content(db,
                          table,
                          row_id,
                          decrypt_func,
                          encrypt_func,
                          logger):
    """
    Re-encrypt a row from ``table`` with ``id`` of ``row_id``.
    """
    q = (select([table.c.content])
         .with_for_update()
         .where(table.c.id == row_id))

    [(content,)] = db.execute(q)

    logger.info("Begin encrypting %s row %s.", table.name, row_id)
    db.execute(
        table
        .update()
        .where(table.c.id == row_id)
        .values(content=encrypt_func(decrypt_func(content)))
    )
    logger.info("Done encrypting %s row %s.", table.name, row_id)
def reencrypt_row_content(db,
                          table,
                          row_id,
                          decrypt_func,
                          encrypt_func,
                          logger):
    q = (select([table.c.content])
         .with_for_update()
         .where(table.c.id == row_id))

    [(content,)] = db.execute(q)

    logger.info("Begin encrypting %s row %s.", table.name, row_id)
    db.execute(
        table
        .update()
        .where(table.c.id == row_id)
        .values(content=encrypt_func(decrypt_func(content)))
    )
    logger.info("Done encrypting %s row %s.", table.name, row_id)
def reencrypt_row_content ( db , table , row_id , decrypt_func , encrypt_func , logger ) : q = ( select ( [ table . c . content ] ) . with_for_update ( ) . where ( table . c . id == row_id ) ) [ ( content , ) ] = db . execute ( q ) logger . info ( "Begin encrypting %s row %s." , table . name , row_id ) db . execute ( table . update ( ) . where ( table . c . id == row_id ) . values ( content = encrypt_func ( decrypt_func ( content ) ) ) ) logger . info ( "Done encrypting %s row %s." , table . name , row_id )
Re-encrypt a row from ``table`` with ``id`` of ``row_id``.
Re - encrypt a row from table with id of row_id .