| |
| |
| :mod:`airflow.hooks.postgres_hook` |
| ================================== |
| |
| .. py:module:: airflow.hooks.postgres_hook |
| |
| |
| |
| |
| |
| |
| |
| Module Contents |
| --------------- |
| |
| |
| |
| |
| |
| |
| .. py:class:: PostgresHook(*args, **kwargs) |
| |
| Bases::class:`airflow.hooks.dbapi_hook.DbApiHook` |
| |
| |
| |
| Interact with Postgres. |
| You can specify ssl parameters in the extra field of your connection |
| as ``{"sslmode": "require", "sslcert": "/path/to/cert.pem", etc}``. |
| |
| Note: For Redshift, use keepalives_idle in the extra connection parameters |
| and set it to less than 300 seconds. |
| |
| |
| |
| |
| |
| |
| .. attribute:: conn_name_attr |
| :annotation: = postgres_conn_id |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| .. attribute:: default_conn_name |
| :annotation: = postgres_default |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| .. attribute:: supports_autocommit |
| :annotation: = True |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| .. method:: get_conn(self) |
| |
| |
| |
| |
| |
| |
| |
| .. method:: copy_expert(self, sql, filename, open=open) |
| |
| |
| Executes SQL using psycopg2 copy_expert method. |
| Necessary to execute COPY command without access to a superuser. |
| |
| Note: if this method is called with a "COPY FROM" statement and |
| the specified input file does not exist, it creates an empty |
| file and no data is loaded, but the operation succeeds. |
| So if users want to be aware when the input file does not exist, |
| they have to check its existence by themselves. |
| |
| |
| |
| |
| |
| |
| |
| .. method:: bulk_load(self, table, tmp_file) |
| |
| |
| Loads a tab-delimited file into a database table |
| |
| |
| |
| |
| |
| |
| |
| .. method:: bulk_dump(self, table, tmp_file) |
| |
| |
| Dumps a database table into a tab-delimited file |
| |
| |
| |
| |
| |
| |
| |
| .. staticmethod:: _serialize_cell(cell, conn) |
| |
| |
| Postgresql will adapt all arguments to the execute() method internally, |
| hence we return cell without any conversion. |
| |
| See http://initd.org/psycopg/docs/advanced.html#adapting-new-types for |
| more information. |
| |
| :param cell: The cell to insert into the table |
| :type cell: object |
| :param conn: The database connection |
| :type conn: connection object |
| :return: The cell |
| :rtype: object |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |