3

Today with the below configuration it is connecting to the default schema of a db , how to configure to connect to a specific schema. enter image description here

references :

https://quarkus.io/guides/reactive-sql-clients#postgresql-2

Any leads will be really helpful.
Jaiprasad
  • 149
  • 11
  • 1
    I'm connecting to a specific schema, but without reactive datasource. I use like this `quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/postgres?currentSchema=broker`. Besides this, I inform `quarkus.datasource.db-kind=postgresql`, `quarkus.datasource.username=postgres` and `quarkus.datasource.password=postgres`. Does it makes any sense for your question? The key idea is to inform `?currentSchema=broker` on the end of the JDBC url. – Felipe Windmoller Jul 15 '22 at 17:54
  • 1
    @FelipeWindmoller I am using quarkus-reactive-pg-client to connect to postgres db , and below is how the configuration needs to be supplied. quarkus.datasource.db-kind = postgresql quarkus.datasource.username = ${DB_USERNAME:postgres} quarkus.datasource.password = ${DB_PASSWORD:postgres} quarkus.datasource.reactive.url = ${DB_URL:postgresql://localhost:5432/sampledb} – Jaiprasad Jul 15 '22 at 17:56
  • 1
    But I am not able to find the configuration to add the schema – Jaiprasad Jul 15 '22 at 17:58
  • 1
    Here is the reference link : https://quarkus.io/guides/reactive-sql-clients#postgresql-2 – Jaiprasad Jul 15 '22 at 17:59
  • @Felipe Windmoller I want to work with reactive datasource , native jdbc I am aware . – Jaiprasad Jul 15 '22 at 18:00
  • is it possible to add `?currentSchema=YOUR_SCHEMA_NAME` to the end of your JDBC URL? Like `quarkus.datasource.reactive.url = ${DB_URL:postgresql://localhost:5432/sampledb?currentSchema=YOUR_SCHEMA_NAME}` – Felipe Windmoller Jul 15 '22 at 18:04
  • 3
    `postgresql://localhost:5432/sampledb?currentSchema=user1` , the application is starting without error , however when I send the query it is not fetching the data from the schema user1 , it is fetching data from the default schema . – Jaiprasad Jul 15 '22 at 18:18
  • sorry to hear that. For me this worked. When I inform `?currentSchema=YOUR_SCHEMA_NAME` on my JDBC URL, I execute my SQLs without informing the schema name and it works. If you can fix your problem, please post here. I don't know if this would help, but [this project](https://github.com/felipewind/fix-trading-simulator/tree/main/broker-back-end) uses conventional database (not reactive) with a specific schema. Good luck! – Felipe Windmoller Jul 15 '22 at 18:32
  • The Vert.xSQL client [doesn't seem to have that configuration at the moment](https://vertx.io/docs/vertx-pg-client/java/#_connection_uri). You can try to open an issue on [the GitHub project](https://github.com/eclipse-vertx/vertx-sql-client/). – Davide D'Alto Jul 15 '22 at 19:48

3 Answers3

5

Adding search_path to the connection uri will fetch results from specific schema.

Below configuration worked.

postgresql://localhost:5432/sampledb?search_path=user1

Below is the class that parse the db configuration

io.vertx.pgclient.impl.PgConnectionUriParser

Thank You David for the leads.

Reference : https://vertx.io/docs/vertx-pg-client/java/#_connection_uri

Jaiprasad
  • 149
  • 11
  • Ah ah ... I read the list of supported properties in the URI twice and missed it :) That's why I didn't expect it to work. Nice that it's there – Davide D'Alto Jul 16 '22 at 10:25
4

UPDATE: you can actually use search_path as connection uri property.

I haven't tested it, but I would try this:

quarkus.datasource.reactive.additional-properties=search_path=user1

search_path is the property used by Postgres to define the schema. The syntax of the configuration is how Smallrye Config reads parameters as map.

Davide D'Alto
  • 7,421
  • 2
  • 16
  • 30
0

Regarding to quarkus 3.1.0

quarkus.datasource.reactive.additional-properties.search_path=my_schema
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 23 '23 at 00:30