datacube.drivers.common_psql.as_role#
- datacube.drivers.common_psql.as_role(conn, role)[source]#
Context manager to temporarily switch database roles.
- E.g.::
- with engine.connect() as conn:
# This is executed as the session role configured into the engine conn.execute(query1) with as_role(conn, “odc_admin”) as conn:
# This is executed as the “odc_admin” role conn.execute(query2)
# This is executed as the session role configured into the engine conn.execute(query3)