--- /dev/null
+.. change::
+ :tags: engine, postgresql, usecase
+ :tickets: 4392
+
+ A :class:`.URL` connection now supports multiple hosts for PostgreSQL. Any
+ query that contains multiple hosts will now group the hosts as a string
+ instead of a tuple of strings. Pull request courtesy Ramon Williams.
query = None
components["query"] = query
+ if components["query"]:
+ if "host" in components["query"]:
+ if not isinstance(components["query"]["host"], str):
+ components["query"]["host"] = ",".join(
+ components["query"]["host"]
+ )
+
if components["username"] is not None:
components["username"] = _rfc_1738_unquote(components["username"])
eq_(cargs, [])
eq_(cparams, {"host": "somehost", "any_random_thing": "yes"})
+ def test_psycopg2_nonempty_connection_string_w_query_two(self):
+ dialect = psycopg2_dialect.dialect()
+ url_string = "postgresql://USER:PASS@/DB?host=hostA"
+ u = url.make_url(url_string)
+ cargs, cparams = dialect.create_connect_args(u)
+ eq_(cargs, [])
+ eq_(cparams["host"], "hostA")
+
+ def test_psycopg2_nonempty_connection_string_w_query_three(self):
+ dialect = psycopg2_dialect.dialect()
+ url_string = (
+ "postgresql://USER:PASS@/DB"
+ "?host=hostA:portA&host=hostB&host=hostC"
+ )
+ u = url.make_url(url_string)
+ cargs, cparams = dialect.create_connect_args(u)
+ eq_(cargs, [])
+ eq_(cparams["host"], "hostA:portA,hostB,hostC")
+
class ExecuteManyMode(object):
__only_on__ = "postgresql+psycopg2"