malthe / ts-postgres

Non-blocking PostgreSQL client for Node.js written in TypeScript.
Other
109 stars 8 forks source link

Configure with connection string #127

Open banool opened 3 weeks ago

banool commented 3 weeks ago

Is there a way to connect just using a postgres connection string, e.g. like this: https://stackoverflow.com/a/20722229/3846032.

I checked the code and couldn't see anything but perhaps I'm missing it.

malthe commented 3 weeks ago

You can use something like https://www.npmjs.com/package/pg-connection-string to parse the string into a config, which can then be used to connect.

Note that the parsed config object is not 1:1 compatible with https://malthe.github.io/ts-postgres/interfaces/Configuration.html – there are some differences which could be relevant, depending on the configuration.