7
7
from singer_sdk import typing as th
8
8
from singer_sdk .target_base import SQLTarget
9
9
10
+ from target_postgres .driver import PSYCOPG3
10
11
from target_postgres .sinks import PostgresSink
11
12
12
13
if t .TYPE_CHECKING :
@@ -40,6 +41,22 @@ def __init__(
40
41
parse_env_config = parse_env_config ,
41
42
validate_config = validate_config ,
42
43
)
44
+ # sqlalchemy_url and dialect+driver are now deprecated in favor of the
45
+ # individual host, port, user, password, and dialect+driver fields.
46
+ if self .config .get ("sqlalchemy_url" ):
47
+ self .logger .warning (
48
+ "The `sqlalchemy_url` configuration option is deprecated. "
49
+ "Please use the `host`, `port`, `user`, `password` "
50
+ "configuration options instead."
51
+ )
52
+
53
+ if (driver := self .config .get ("dialect+driver" )) and driver != PSYCOPG3 :
54
+ self .logger .warning (
55
+ "The `dialect+driver` configuration option is deprecated. "
56
+ f"Please set it to `{ PSYCOPG3 } `, as this will be the hard-coded "
57
+ "value in the future."
58
+ )
59
+
43
60
# There's a few ways to do this in JSON Schema but it is schema draft dependent.
44
61
# https://stackoverflow.com/questions/38717933/jsonschema-attribute-conditionally-required # noqa: E501
45
62
assert (self .config .get ("sqlalchemy_url" ) is not None ) or (
@@ -98,49 +115,34 @@ def __init__(
98
115
th .Property (
99
116
"host" ,
100
117
th .StringType ,
101
- description = (
102
- "Hostname for postgres instance. "
103
- + "Note if sqlalchemy_url is set this will be ignored."
104
- ),
118
+ description = "Hostname for postgres instance." ,
105
119
),
106
120
th .Property (
107
121
"port" ,
108
122
th .IntegerType ,
109
123
default = 5432 ,
110
- description = (
111
- "The port on which postgres is awaiting connection. "
112
- + "Note if sqlalchemy_url is set this will be ignored."
113
- ),
124
+ description = "The port on which postgres is awaiting connections." ,
114
125
),
115
126
th .Property (
116
127
"user" ,
117
128
th .StringType ,
118
- description = (
119
- "User name used to authenticate. "
120
- + "Note if sqlalchemy_url is set this will be ignored."
121
- ),
129
+ description = "User name used to authenticate." ,
122
130
),
123
131
th .Property (
124
132
"password" ,
125
133
th .StringType ,
126
- description = (
127
- "Password used to authenticate. "
128
- "Note if sqlalchemy_url is set this will be ignored."
129
- ),
134
+ description = "Password used to authenticate." ,
130
135
),
131
136
th .Property (
132
137
"database" ,
133
138
th .StringType ,
134
- description = (
135
- "Database name. "
136
- + "Note if sqlalchemy_url is set this will be ignored."
137
- ),
139
+ description = "Database name." ,
138
140
),
139
141
th .Property (
140
142
"sqlalchemy_url" ,
141
143
th .StringType ,
142
144
description = (
143
- "SQLAlchemy connection string. "
145
+ "DEPRECATED. SQLAlchemy connection string. "
144
146
+ "This will override using host, user, password, port, "
145
147
+ "dialect, and all ssl settings. Note that you must escape password "
146
148
+ "special characters properly. See "
@@ -150,12 +152,11 @@ def __init__(
150
152
th .Property (
151
153
"dialect+driver" ,
152
154
th .StringType ,
153
- default = "postgresql+psycopg" ,
155
+ default = PSYCOPG3 ,
154
156
description = (
155
- "Dialect+driver see "
157
+ "DEPRECATED. Dialect+driver see "
156
158
+ "https://docs.sqlalchemy.org/en/20/core/engines.html. "
157
- + "Generally just leave this alone. "
158
- + "Note if sqlalchemy_url is set this will be ignored."
159
+ + "Generally just leave this alone."
159
160
),
160
161
),
161
162
th .Property (
@@ -215,7 +216,6 @@ def __init__(
215
216
+ " ssl_certificate_authority and ssl_mode for further customization."
216
217
+ " To use a client certificate to authenticate yourself to the server,"
217
218
+ " use ssl_client_certificate_enable instead."
218
- + " Note if sqlalchemy_url is set this will be ignored."
219
219
),
220
220
),
221
221
th .Property (
@@ -227,7 +227,6 @@ def __init__(
227
227
+ " authentication to the server. Use ssl_client_certificate and"
228
228
+ " ssl_client_private_key for further customization. To use SSL to"
229
229
+ " verify the server's identity, use ssl_enable instead."
230
- + " Note if sqlalchemy_url is set this will be ignored."
231
230
),
232
231
),
233
232
th .Property (
@@ -249,7 +248,6 @@ def __init__(
249
248
"The certificate authority that should be used to verify the server's"
250
249
+ " identity. Can be provided either as the certificate itself (in"
251
250
+ " .env) or as a filepath to the certificate."
252
- + " Note if sqlalchemy_url is set this will be ignored."
253
251
),
254
252
),
255
253
th .Property (
@@ -271,7 +269,6 @@ def __init__(
271
269
"The private key for the certificate you provided. Can be provided"
272
270
+ " either as the certificate itself (in .env) or as a filepath to the"
273
271
+ " certificate."
274
- + " Note if sqlalchemy_url is set this will be ignored."
275
272
),
276
273
),
277
274
th .Property (
0 commit comments