[DATA] Helpers for PostgreSQL/PostGIS (schema discovery, psql, pg_dump,...)
MIT License
Helpers for PostgreSQL/PostGIS (schema discovery, psql, pg_dump,...)
Connection to the database relies on PostgreSQL environment variables (PGHOST, PGDATABASE, etc.)
Concept | Description |
---|---|
Database | Database connexion wrapper (Client from pg ) |
Catalog | Database schema explorer (schemas, tables, columns, constraints) |
SourceManager | Manage a per-schema source table to track source when loading foreign data |
Table | JS model describing an SQL table |
Column | JS model describing an SQL column |
Client
wrapper for pg
module providing helpers.
let database = await Database.createDatabase();
let activites = await database.query('SELECT * FROM pg_stat_activity');
await database.close();
let schemaNames = await database.getSchemaNames();
await database.hasSchema('public');
let tableNames = await database.getTableNames('public');
let tables = await database.getTables('public');
const {backup} = require('@mborne/postgis-helper');
/*
* Rely on pg_dump to backup 'cadastre' schema as :
* - /mnt/postgis-backup/cadastre.schema.sql
* - /mnt/postgis-backup/cadastre.data.sql
*/
await backup({
schemaName: 'cadastre',
targetDir: '/mnt/postgis-backup'
});
createdb test
PGDATABASE=test npm run test
See CHANGELOG.md