c# - Npgsql connection string, dynamic database querying -


i have following connection string:

npgsqlconnection conn = new npgsqlconnection($"server={_server};port={_port};user id={_userid};password={_password};database={database}");

where database selected collection of countrycodes (gb, us, de etc) , corresponding database queried.

the countrycode selected series of methods determine latitude , longitude (utm) lie on map (ie 51.503471, -0.119586 output: gb because it's within bounding box of great britain). lat/lon values passed in user, different each query, , possibly in different countries (and different database).

the rest of connection data stays same, server/userid etc not changing, database being queried may change each time user submits lat/lon.

is there way hold connection open without specified database in postgres/npgsql, or have reopen (and close @ end of query) connection each time query submitted?

no, postgresql connection connection specific database - can't switch database retaining same connection.

is there particular reason separate data different databases? separate schemas within same database may serve same purpose without forcing reconnect etc. if must use different databases, connection pooling may mitigate performance impact of closing/opening connections.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -