Skip to content

CONNECTION

Specify a named database connection for the endpoint.

Keywords

connection, connection_name

Syntax

connection <connection-name>
connection_name <connection-name>

Examples

Use Named Connection

sql
comment on function get_analytics() is
'HTTP GET
connection analytics_db';

Reporting Database

sql
comment on function generate_report() is
'HTTP GET
connection_name reporting';

Read Replica

sql
comment on function read_heavy_query() is
'HTTP GET
connection read_replica';

Behavior

  • References a connection string defined in ConnectionStrings configuration
  • Allows different endpoints to use different databases
  • Requires UseMultipleConnections: true in NpgsqlRest options
  • See Connection Settings configuration

Released under the MIT License.