ts-postgres icon indicating copy to clipboard operation
ts-postgres copied to clipboard

Configure with connection string

Open banool opened this issue 1 year ago • 1 comments

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.

banool avatar Oct 22 '24 13:10 banool

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.

malthe avatar Oct 22 '24 14:10 malthe