Skip to content
Written with Claude

CONNECTION

Also known as

connection_name (with or without @ prefix)

Specify a named database connection for the endpoint.

Syntax

code
@connection <connection-name>
@connection_name <connection-name>

Examples

Use Named Connection

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

Reporting Database

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

Read Replica

sql
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

See Also

Comments