Postgresql Proxy
Maintained. Last release 3 days ago, commits in 1 of the last 26 weeks. Weaker on commit activity.
pip install postgresql-proxyPostgresql Proxy
Serves as a proper server that Postgresql clients can connect to. Can modify packets that pass through.
Currently used for rewriting queries to force proper use of postgres-hll module by external proprietary software that doesn't know about that functionality
Installing
Requires Python 3.13+.
- Clone the repository:
git clone git@github.com:localstack/postgresql-proxy.git cd postgresql-proxy - Install dependencies into a local virtualenv:
make install - Copy the example config and edit it for your environment:
cp config.yml.example config.yml
Configuring
In the config.yml file you can define the following things
Plugins
A list of dynamically loaded modules that reside in the plugins directory. These plugins can be used in later configuration, to intercept queries, commands, or responses. View plugin documentation for example plugins for more details on how to do that.
Settings
General application settings. Currently the following settings are used
log-level- the log level for the general log. See python logging for more details about the logging functionalitygeneral-log- the location for the general log. All general messages go in there.intercept-log- the location for the intercept log. Intercepted messages and return values from various enabled plugins will be written there. This log can be quite verbose as it contains the full binary messages being circulated.
Make sure to manage the logs yourself, as they accumulate and take up disk space.
Instances
instances is a list of instance definitions. Each instance has a listening port and redirects to a different postgresql instance. They have individual configurations for which message interceptors to use. It requires, for every instance, a listen directive and redirect directive.
-
listendirective, that must contain aname(for logging purposes),hostand for the listening socket. This is the host and port that external tools will connect to, as if it were the actual PostgreSql server.