{"library":"pg-database-url","title":"PostgreSQL Connection URL Builder","description":"pg-database-url is a minimalist utility that constructs a PostgreSQL connection string (URI) from a structured JavaScript configuration object. Released as version 0.1.0, this package targets older Node.js environments (specifically `>=4.2.0`) and exclusively uses CommonJS modules. As of the last observed activity, the project appears to be abandoned, with no significant updates or maintenance in recent years (last commit over 11 years ago). Its primary function is to simplify the creation of connection strings for use with PostgreSQL client libraries like `node-postgres`, converting host, port, database, username, and password into a standard `postgres://` URI format. It does not offer advanced features like connection pooling, query building, or extensive validation, focusing solely on the URI generation aspect. There are no clear release cadences or stated differentiators, as it is a very specific, single-purpose library.","language":"javascript","status":"abandoned","last_verified":"Wed Apr 22","install":{"commands":["npm install pg-database-url"],"cli":null},"imports":["const pgUrl = require('pg-database-url')","const pgUrl = require('pg-database-url')"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const pgUrl = require('pg-database-url');\n\n// Basic configuration from environment variables or a config file\nconst dbConfig = {\n  host: process.env.DB_HOST ?? 'localhost',\n  port: parseInt(process.env.DB_PORT ?? '5432', 10),\n  database: process.env.DB_NAME ?? 'mydb',\n  username: process.env.DB_USER ?? 'user',\n  password: process.env.DB_PASSWORD ?? 'pass'\n};\n\nconst connectionString = pgUrl(dbConfig);\nconsole.log('Generated Connection String:', connectionString);\n\n// Example with `node-postgres` (install separately: npm install pg)\n// const { Client } = require('pg');\n// const client = new Client({ connectionString });\n//\n// async function testConnection() {\n//   try {\n//     await client.connect();\n//     const res = await client.query('SELECT NOW() as current_time');\n//     console.log('Database time:', res.rows[0].current_time);\n//   } catch (err) {\n//     console.error('Database connection error:', err);\n//   } finally {\n//     await client.end();\n//   }\n// }\n//\n// testConnection();","lang":"javascript","description":"This quickstart demonstrates how to generate a PostgreSQL connection string from a configuration object, suitable for use with client libraries like `node-postgres`. It includes placeholder environment variables for security and best practices.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}