Git Product home page Git Product logo

pgtools's People

Contributors

aarontrank avatar adriaanvanrossum avatar alechirsch avatar bcoe avatar dependabot[bot] avatar olalonde avatar sunwukung avatar thomwright avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pgtools's Issues

Interference with pg-promise

I am a newbie regarding nodejs and promises, learning as I go... :)

I have been having a problem where this module interferes with pg-promise. Pg-promise will connect to the public database instead of the specified database.. it seems to be reusing the connection created by this module. When I don't use pgtools functionality pg-promise will work as expected.

This might be due to the connection not being closed properly.

Silent Failure node v14

Issue:
pgtools fails to return a status when run.
This happens in cli and programmatic use.

Reproduce problem:
Using node v14.14.0, postgres v13.0
Attempt to connect with an invalid configuration or with a valid configuration. In both cases, nothing is returned. The callbacks are ignored, no errors or notice of success is displayed.

I've tested that this problem does not occur in node v12.18.3, postgres v12.4
I suspect that this is an issue with node v14.
A similar issue seems to be happening in sequelize/sequelize#12158
What seemed to work there was updating the pg dependency.

Solution:
This is what @sohel-ahmed-ansari proposes #21, which solves this issue.
I've tested that solution on node v14.14.0 and I only did simple tests but it seems to work properly.

How I tested that:

  • npm install npm-force-resolutions
  • add to package.json "resolutions": { "pg": "8.4.0", "pg-connection-string": "2.4.0" }
    and new npm script
    "preinstall": "npx npm-force-resolutions"
    Source: https://stackoverflow.com/a/62956076

To avoid this workaround, one can also do manually what pgtools does: use pg directly, connecting to a default database first.

WebServer type

When connecting to a webserver in the config options does pgtools need it to be tcp, udp, http, or something else?

db owner needed

Hi all, it would be nice to be able to specify owner of created db.

New release to publish with the Yargs patch?

In March, the project seemed to get a good Yargs patch which fixes numerous transitive security vulnerabilities.

However, seems the version was not published - the latest to download from Npm is v1.0.0 which still contains Yargs v5.x.

Is it possible to cut a release including the most recent dep upgrade?

Thanks!

Ref: #50

dropdb fails silently if database is open in pgAdmin3

dropdb errors are working for me generally - ie the following code will reach the console.error line if the database doesn't already exist:

pgtools
    .dropdb(config, testDbName)
    .catch((error)=>{
      console.log(error);
    })

However if I happen to have the database open in pgAdmin3 it won't drop the database and it won't throw an error.

Move tests to GitHub actions

From the travis-ci.org website:

Please be aware travis-ci.org will be shutting down in several weeks, with all accounts migrating to travis-ci.com. Please stay tuned here for more information.

It's a good moment to move to GitHub actions.

  • Move tests from Travis to GitHub
  • Add timeout-minutes to something like 5 (GitHub had some errors in the past where jobs wouldn't stop)
  • Use harmon758/postgresql-action for PostgreSQL Action

pgtools not connecting to postgres with SSL certificate

pgtools not connecting to postgres with SSL enabled.

throws error

ERR: (node:67) UnhandledPromiseRejectionWarning: error: SSL required
at Parser.parseErrorMessage (/opt/meshcentral/node_modules/pg-protocol/dist/parser.js:287:98)
at Parser.handlePacket (/opt/meshcentral/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/opt/meshcentral/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket. (/opt/meshcentral/node_modules/pg-protocol/dist/index.js:11:42)
at Socket.emit (events.js:314:20)
at addChunk (_stream_readable.js:297:12)
at readableAddChunk (_stream_readable.js:272:9)
at Socket.Readable.push (_stream_readable.js:213:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)

update yargs dep

yargs 5.0.0 uses yargs-parser 3.2.0 which has a vulnerability, is it possible to use a newer version of yargs?

Unhandled rejection error when trying to swallow dropdb() failure

I was trying to implement what this issue was asking for at a higher level: #3

I wrote this out:

import pgtools from 'pgtools'
import CONFIG from './db-config.json'

function handleDropErrors (err) {
  console.dir(err.message.indexOf(`does not exist`), {colors: true, depth: 3})
  if (err.message.indexOf(`does not exist`) === -1) {
    console.error(err)
  } else {
    console.error(`got here`, err)
    // createDb()
    return Promise.resolve()
  }
}

function createDb() {
  // calls pgtools.createdb()
}

pgtools.dropdb(CONFIG, CONFIG.database)
  .then(createDb, handleDropErrors)
  .catch(handleDropErrors)

But I keep getting the following stack trace:

Unhandled rejection error: database "mydb" does not exist
    at Connection.parseE (/Users/mmarcus/dev/emma-exercise/node_modules/pgtools/node_modules/pg/lib/connection.js:567:11)
    at Connection.parseMessage (/Users/mmarcus/dev/emma-exercise/node_modules/pgtools/node_modules/pg/lib/connection.js:391:17)
    at Socket.<anonymous> (/Users/mmarcus/dev/emma-exercise/node_modules/pgtools/node_modules/pg/lib/connection.js:129:22)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at TCP.onread (net.js:548:20)

AFACT, I am handling the error, I'm just choosing to swallow it if the error is a specific error.

What's even more odd, is that w/ both native and Bluebird promises.. this kind of logic seems to work just fine for "swallowing" a promise rejection.

Native: https://repl.it/JgPz
Bluebird: https://repl.it/JgQa/1

I'm at a loss at this point :-(

pgtools.createdb is failing silently

Hello. Running current version of your tool. Running node 14.x. I have a script (https://github.com/RobStafford/To-Do-Calendar/blob/main/database/schemaPostgres.js) which has run successfully dozens of times. Now, when you run it, a console.log before or after the .createdb command fires, but nothing inside the command. Nothing is logged--no successes or failures. I have a teammate who was having the same problem the day before, then mine started acting the same way. That makes me suspect it might be related to a PR on our project, but I can't for the life of me see what the problem is. Help?

Conditionally drop/create databases

Given that the current code errors out if you try to create an existing database, wouldn't it be better to just create it if it doesn't exist? Conversely for dropping, only if the table exists should you drop?
If this is acceptable, I could probably send a pull request in fairly quickly.

Maintained alternative?

I love this package, but it's not maintained anymore.

Does anybody know an alternative?

Or are you open to give more maintainers access to pgtools, @olalonde?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.