sfackler / rust-postgres

Native PostgreSQL driver for the Rust programming language
Apache License 2.0
3.43k stars 436 forks source link

Question: readonly connection #1046

Closed stevenliebregt closed 1 year ago

stevenliebregt commented 1 year ago

Hi, is it possible to have a client connect as read-only? I see that there is such a functionality on transaction but could not find anything for the main client.

sfackler commented 1 year ago

If you want to enforce that a connection can never make any modifications you'd want to create a read-only user.

You may be able to do it for an individual connection by setting options to -c default_transaction_read_only=true in the connection configuration but I haven't personally tried that.