apache-airflow-providers-postgres 5.14.0__tar.gz → 6.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: apache-airflow-providers-postgres
3
- Version: 5.14.0
3
+ Version: 6.0.0
4
4
  Summary: Provider package apache-airflow-providers-postgres for Apache Airflow
5
5
  Keywords: airflow-provider,postgres,airflow,integration
6
6
  Author-email: Apache Software Foundation <dev@airflow.apache.org>
@@ -21,20 +21,19 @@ Classifier: Programming Language :: Python :: 3.11
21
21
  Classifier: Programming Language :: Python :: 3.12
22
22
  Classifier: Topic :: System :: Monitoring
23
23
  Requires-Dist: apache-airflow-providers-common-sql>=1.20.0
24
- Requires-Dist: apache-airflow>=2.8.0
24
+ Requires-Dist: apache-airflow>=2.9.0
25
+ Requires-Dist: asyncpg>=0.30.0
25
26
  Requires-Dist: psycopg2-binary>=2.9.4
26
27
  Requires-Dist: apache-airflow-providers-amazon>=2.6.0 ; extra == "amazon"
27
- Requires-Dist: apache-airflow-providers-common-sql ; extra == "common-sql"
28
28
  Requires-Dist: apache-airflow-providers-openlineage ; extra == "openlineage"
29
29
  Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
30
- Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.14.0/changelog.html
31
- Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.14.0
30
+ Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.0.0/changelog.html
31
+ Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.0.0
32
32
  Project-URL: Slack Chat, https://s.apache.org/airflow-slack
33
33
  Project-URL: Source Code, https://github.com/apache/airflow
34
- Project-URL: Twitter, https://twitter.com/ApacheAirflow
34
+ Project-URL: Twitter, https://x.com/ApacheAirflow
35
35
  Project-URL: YouTube, https://www.youtube.com/channel/UCSXwxpWZQ7XZ1WL3wqevChA/
36
36
  Provides-Extra: amazon
37
- Provides-Extra: common-sql
38
37
  Provides-Extra: openlineage
39
38
 
40
39
 
@@ -81,7 +80,7 @@ Provides-Extra: openlineage
81
80
 
82
81
  Package ``apache-airflow-providers-postgres``
83
82
 
84
- Release: ``5.14.0``
83
+ Release: ``6.0.0``
85
84
 
86
85
 
87
86
  `PostgreSQL <https://www.postgresql.org/>`__
@@ -94,7 +93,7 @@ This is a provider package for ``postgres`` provider. All classes for this provi
94
93
  are in ``airflow.providers.postgres`` python package.
95
94
 
96
95
  You can find package information and changelog for the provider
97
- in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.14.0/>`_.
96
+ in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.0.0/>`_.
98
97
 
99
98
  Installation
100
99
  ------------
@@ -111,9 +110,10 @@ Requirements
111
110
  ======================================= ==================
112
111
  PIP package Version required
113
112
  ======================================= ==================
114
- ``apache-airflow`` ``>=2.8.0``
113
+ ``apache-airflow`` ``>=2.9.0``
115
114
  ``apache-airflow-providers-common-sql`` ``>=1.20.0``
116
115
  ``psycopg2-binary`` ``>=2.9.4``
116
+ ``asyncpg`` ``>=0.30.0``
117
117
  ======================================= ==================
118
118
 
119
119
  Cross provider package dependencies
@@ -138,4 +138,4 @@ Dependent package
138
138
  ============================================================================================================== ===============
139
139
 
140
140
  The changelog for the provider package can be found in the
141
- `changelog <https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.14.0/changelog.html>`_.
141
+ `changelog <https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.0.0/changelog.html>`_.
@@ -42,7 +42,7 @@
42
42
 
43
43
  Package ``apache-airflow-providers-postgres``
44
44
 
45
- Release: ``5.14.0``
45
+ Release: ``6.0.0``
46
46
 
47
47
 
48
48
  `PostgreSQL <https://www.postgresql.org/>`__
@@ -55,7 +55,7 @@ This is a provider package for ``postgres`` provider. All classes for this provi
55
55
  are in ``airflow.providers.postgres`` python package.
56
56
 
57
57
  You can find package information and changelog for the provider
58
- in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.14.0/>`_.
58
+ in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.0.0/>`_.
59
59
 
60
60
  Installation
61
61
  ------------
@@ -72,9 +72,10 @@ Requirements
72
72
  ======================================= ==================
73
73
  PIP package Version required
74
74
  ======================================= ==================
75
- ``apache-airflow`` ``>=2.8.0``
75
+ ``apache-airflow`` ``>=2.9.0``
76
76
  ``apache-airflow-providers-common-sql`` ``>=1.20.0``
77
77
  ``psycopg2-binary`` ``>=2.9.4``
78
+ ``asyncpg`` ``>=0.30.0``
78
79
  ======================================= ==================
79
80
 
80
81
  Cross provider package dependencies
@@ -99,4 +100,4 @@ Dependent package
99
100
  ============================================================================================================== ===============
100
101
 
101
102
  The changelog for the provider package can be found in the
102
- `changelog <https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.14.0/changelog.html>`_.
103
+ `changelog <https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.0.0/changelog.html>`_.
@@ -29,11 +29,11 @@ from airflow import __version__ as airflow_version
29
29
 
30
30
  __all__ = ["__version__"]
31
31
 
32
- __version__ = "5.14.0"
32
+ __version__ = "6.0.0"
33
33
 
34
34
  if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
35
- "2.8.0"
35
+ "2.9.0"
36
36
  ):
37
37
  raise RuntimeError(
38
- f"The package `apache-airflow-providers-postgres:{__version__}` needs Apache Airflow 2.8.0+"
38
+ f"The package `apache-airflow-providers-postgres:{__version__}` needs Apache Airflow 2.9.0+"
39
39
  )
@@ -28,8 +28,9 @@ def get_provider_info():
28
28
  "name": "PostgreSQL",
29
29
  "description": "`PostgreSQL <https://www.postgresql.org/>`__\n",
30
30
  "state": "ready",
31
- "source-date-epoch": 1731570750,
31
+ "source-date-epoch": 1734536300,
32
32
  "versions": [
33
+ "6.0.0",
33
34
  "5.14.0",
34
35
  "5.13.1",
35
36
  "5.13.0",
@@ -72,9 +73,10 @@ def get_provider_info():
72
73
  "1.0.0",
73
74
  ],
74
75
  "dependencies": [
75
- "apache-airflow>=2.8.0",
76
+ "apache-airflow>=2.9.0",
76
77
  "apache-airflow-providers-common-sql>=1.20.0",
77
78
  "psycopg2-binary>=2.9.4",
79
+ "asyncpg>=0.30.0",
78
80
  ],
79
81
  "additional-extras": [{"name": "amazon", "dependencies": ["apache-airflow-providers-amazon>=2.6.0"]}],
80
82
  "integrations": [
@@ -88,12 +90,6 @@ def get_provider_info():
88
90
  "tags": ["software"],
89
91
  }
90
92
  ],
91
- "operators": [
92
- {
93
- "integration-name": "PostgreSQL",
94
- "python-modules": ["airflow.providers.postgres.operators.postgres"],
95
- }
96
- ],
97
93
  "hooks": [
98
94
  {
99
95
  "integration-name": "PostgreSQL",
@@ -18,19 +18,18 @@
18
18
  from __future__ import annotations
19
19
 
20
20
  import os
21
- import warnings
21
+ from collections.abc import Iterable
22
22
  from contextlib import closing
23
23
  from copy import deepcopy
24
- from typing import TYPE_CHECKING, Any, Iterable, Union
24
+ from typing import TYPE_CHECKING, Any, Union
25
25
 
26
26
  import psycopg2
27
27
  import psycopg2.extensions
28
28
  import psycopg2.extras
29
- from deprecated import deprecated
30
29
  from psycopg2.extras import DictCursor, NamedTupleCursor, RealDictCursor
31
30
  from sqlalchemy.engine import URL
32
31
 
33
- from airflow.exceptions import AirflowProviderDeprecationWarning
32
+ from airflow.exceptions import AirflowException
34
33
  from airflow.providers.common.sql.hooks.sql import DbApiHook
35
34
 
36
35
  if TYPE_CHECKING:
@@ -87,49 +86,33 @@ class PostgresHook(DbApiHook):
87
86
  hook_name = "Postgres"
88
87
  supports_autocommit = True
89
88
  supports_executemany = True
89
+ ignored_extra_options = {
90
+ "iam",
91
+ "redshift",
92
+ "redshift-serverless",
93
+ "cursor",
94
+ "cluster-identifier",
95
+ "workgroup-name",
96
+ "aws_conn_id",
97
+ "sqlalchemy_scheme",
98
+ "sqlalchemy_query",
99
+ }
90
100
 
91
101
  def __init__(
92
102
  self, *args, options: str | None = None, enable_log_db_messages: bool = False, **kwargs
93
103
  ) -> None:
94
- if "schema" in kwargs:
95
- warnings.warn(
96
- 'The "schema" arg has been renamed to "database" as it contained the database name.'
97
- 'Please use "database" to set the database name.',
98
- AirflowProviderDeprecationWarning,
99
- stacklevel=2,
100
- )
101
- kwargs["database"] = kwargs["schema"]
102
104
  super().__init__(*args, **kwargs)
103
105
  self.conn: connection = None
104
106
  self.database: str | None = kwargs.pop("database", None)
105
107
  self.options = options
106
108
  self.enable_log_db_messages = enable_log_db_messages
107
109
 
108
- @property
109
- @deprecated(
110
- reason=(
111
- 'The "schema" variable has been renamed to "database" as it contained the database name.'
112
- 'Please use "database" to get the database name.'
113
- ),
114
- category=AirflowProviderDeprecationWarning,
115
- )
116
- def schema(self):
117
- return self.database
118
-
119
- @schema.setter
120
- @deprecated(
121
- reason=(
122
- 'The "schema" variable has been renamed to "database" as it contained the database name.'
123
- 'Please use "database" to set the database name.'
124
- ),
125
- category=AirflowProviderDeprecationWarning,
126
- )
127
- def schema(self, value):
128
- self.database = value
129
-
130
110
  @property
131
111
  def sqlalchemy_url(self) -> URL:
132
- conn = self.get_connection(self.get_conn_id())
112
+ conn = self.connection
113
+ query = conn.extra_dejson.get("sqlalchemy_query", {})
114
+ if not isinstance(query, dict):
115
+ raise AirflowException("The parameter 'sqlalchemy_query' must be of type dict!")
133
116
  return URL.create(
134
117
  drivername="postgresql",
135
118
  username=conn.login,
@@ -137,6 +120,7 @@ class PostgresHook(DbApiHook):
137
120
  host=conn.host,
138
121
  port=conn.port,
139
122
  database=self.database or conn.schema,
123
+ query=query,
140
124
  )
141
125
 
142
126
  def _get_cursor(self, raw_cursor: str) -> CursorType:
@@ -175,15 +159,7 @@ class PostgresHook(DbApiHook):
175
159
  conn_args["options"] = self.options
176
160
 
177
161
  for arg_name, arg_val in conn.extra_dejson.items():
178
- if arg_name not in [
179
- "iam",
180
- "redshift",
181
- "redshift-serverless",
182
- "cursor",
183
- "cluster-identifier",
184
- "workgroup-name",
185
- "aws_conn_id",
186
- ]:
162
+ if arg_name not in self.ignored_extra_options:
187
163
  conn_args[arg_name] = arg_val
188
164
 
189
165
  self.conn = psycopg2.connect(**conn_args)
@@ -27,7 +27,7 @@ build-backend = "flit_core.buildapi"
27
27
 
28
28
  [project]
29
29
  name = "apache-airflow-providers-postgres"
30
- version = "5.14.0"
30
+ version = "6.0.0"
31
31
  description = "Provider package apache-airflow-providers-postgres for Apache Airflow"
32
32
  readme = "README.rst"
33
33
  authors = [
@@ -55,17 +55,18 @@ classifiers = [
55
55
  requires-python = "~=3.9"
56
56
  dependencies = [
57
57
  "apache-airflow-providers-common-sql>=1.20.0",
58
- "apache-airflow>=2.8.0",
58
+ "apache-airflow>=2.9.0",
59
+ "asyncpg>=0.30.0",
59
60
  "psycopg2-binary>=2.9.4",
60
61
  ]
61
62
 
62
63
  [project.urls]
63
- "Documentation" = "https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.14.0"
64
- "Changelog" = "https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.14.0/changelog.html"
64
+ "Documentation" = "https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.0.0"
65
+ "Changelog" = "https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.0.0/changelog.html"
65
66
  "Bug Tracker" = "https://github.com/apache/airflow/issues"
66
67
  "Source Code" = "https://github.com/apache/airflow"
67
68
  "Slack Chat" = "https://s.apache.org/airflow-slack"
68
- "Twitter" = "https://twitter.com/ApacheAirflow"
69
+ "Twitter" = "https://x.com/ApacheAirflow"
69
70
  "YouTube" = "https://www.youtube.com/channel/UCSXwxpWZQ7XZ1WL3wqevChA/"
70
71
 
71
72
  [project.entry-points."apache_airflow_provider"]
@@ -74,9 +75,6 @@ provider_info = "airflow.providers.postgres.get_provider_info:get_provider_info"
74
75
  "amazon" = [
75
76
  "apache-airflow-providers-amazon>=2.6.0",
76
77
  ]
77
- "common.sql" = [
78
- "apache-airflow-providers-common-sql",
79
- ]
80
78
  "openlineage" = [
81
79
  "apache-airflow-providers-openlineage",
82
80
  ]
@@ -1,17 +0,0 @@
1
- #
2
- # Licensed to the Apache Software Foundation (ASF) under one
3
- # or more contributor license agreements. See the NOTICE file
4
- # distributed with this work for additional information
5
- # regarding copyright ownership. The ASF licenses this file
6
- # to you under the Apache License, Version 2.0 (the
7
- # "License"); you may not use this file except in compliance
8
- # with the License. You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing,
13
- # software distributed under the License is distributed on an
14
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
- # KIND, either express or implied. See the License for the
16
- # specific language governing permissions and limitations
17
- # under the License.
@@ -1,87 +0,0 @@
1
- #
2
- # Licensed to the Apache Software Foundation (ASF) under one
3
- # or more contributor license agreements. See the NOTICE file
4
- # distributed with this work for additional information
5
- # regarding copyright ownership. The ASF licenses this file
6
- # to you under the Apache License, Version 2.0 (the
7
- # "License"); you may not use this file except in compliance
8
- # with the License. You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing,
13
- # software distributed under the License is distributed on an
14
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
- # KIND, either express or implied. See the License for the
16
- # specific language governing permissions and limitations
17
- # under the License.
18
- from __future__ import annotations
19
-
20
- import warnings
21
- from typing import ClassVar, Mapping
22
-
23
- from deprecated import deprecated
24
-
25
- from airflow.exceptions import AirflowProviderDeprecationWarning
26
- from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
27
-
28
-
29
- @deprecated(
30
- reason=(
31
- "Please use `airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator`."
32
- "Also, you can provide `hook_params={'schema': <database>}`."
33
- ),
34
- category=AirflowProviderDeprecationWarning,
35
- )
36
- class PostgresOperator(SQLExecuteQueryOperator):
37
- """
38
- Executes sql code in a specific Postgres database.
39
-
40
- This class is deprecated.
41
-
42
- Please use :class:`airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator`.
43
-
44
- :param sql: the SQL code to be executed as a single string, or
45
- a list of str (sql statements), or a reference to a template file.
46
- Template references are recognized by str ending in '.sql'
47
- :param postgres_conn_id: The :ref:`postgres conn id <howto/connection:postgres>`
48
- reference to a specific postgres database.
49
- :param autocommit: if True, each command is automatically committed.
50
- (default value: False)
51
- :param parameters: (optional) the parameters to render the SQL query with.
52
- :param database: name of database which overwrite defined one in connection
53
- :param runtime_parameters: a mapping of runtime params added to the final sql being executed.
54
- For example, you could set the schema via `{"search_path": "CUSTOM_SCHEMA"}`.
55
- Deprecated - use `hook_params={'options': '-c <connection_options>'}` instead.
56
- """
57
-
58
- template_fields_renderers: ClassVar[dict] = {
59
- **SQLExecuteQueryOperator.template_fields_renderers,
60
- "sql": "postgresql",
61
- }
62
- ui_color = "#ededed"
63
-
64
- def __init__(
65
- self,
66
- *,
67
- postgres_conn_id: str = "postgres_default",
68
- database: str | None = None,
69
- runtime_parameters: Mapping | None = None,
70
- **kwargs,
71
- ) -> None:
72
- if database is not None:
73
- hook_params = kwargs.pop("hook_params", {})
74
- kwargs["hook_params"] = {"database": database, **hook_params}
75
-
76
- if runtime_parameters:
77
- warnings.warn(
78
- """`runtime_parameters` is deprecated.
79
- Please use `hook_params={'options': '-c <connection_options>}`.""",
80
- AirflowProviderDeprecationWarning,
81
- stacklevel=2,
82
- )
83
- hook_params = kwargs.pop("hook_params", {})
84
- options = " ".join(f"-c {param}={val}" for param, val in runtime_parameters.items())
85
- kwargs["hook_params"] = {"options": options, **hook_params}
86
-
87
- super().__init__(conn_id=postgres_conn_id, **kwargs)