Coder Social home page Coder Social logo

Fails to connect to psql about stellar HOT 11 CLOSED

fastmonkeys avatar fastmonkeys commented on August 19, 2024
Fails to connect to psql

from stellar.

Comments (11)

ramonakira avatar ramonakira commented on August 19, 2024 1

I'm not sure if this is related, but this worked for me:
postgresql://[email protected]:5432/

e.g. add the username of the database and use the IP instead of hostname localhost.

from stellar.

joshma avatar joshma commented on August 19, 2024 1

Has anyone else gotten this to work? I've tried a variety of URLs, including the full one postgresql://joshma@localhost:5432/mydb and it won't work, while psql -h localhost -p 5432 -U joshma mydb works fine.

from stellar.

nobuf avatar nobuf commented on August 19, 2024

I've faced the same error. After reading sqlalchemy's document a little I tried to pass postgresql+psycopg2://ubuntu:@/testdb?host=/var/run/postgresql, but it asks me my db name again Please enter the name of the database (eg. projectdb): and returns another error if I type the db name:

Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/testdb/.s.PGSQL.5432"?`

The socket file should be at /var/run/postgresql/.s.PGSQL.5432.

database_exists and other methods in stellar's code do not seem supporting additional params like specifying unix socket. After created a user with alter user newuser createdb and allowed tcp access in pg_hba.conf, postgresql+psycopg2://newuser:newpass@localhost:5432/ is working in my case.

from stellar.

jayzeng avatar jayzeng commented on August 19, 2024

@ramonakira I tried what you suggested with no luck. Got the exact same error.

from stellar.

zosiu avatar zosiu commented on August 19, 2024

@nobuf 👍
postgresql+psycopg2://newuser:newpass@localhost:5432/ has worked for me too

from stellar.

pypingou avatar pypingou commented on August 19, 2024

The root of this problem is: https://github.com/fastmonkeys/stellar/blob/master/stellar/command.py#L160

If you print the OperationalError exception what you get most of the time is database does not exists and that's due to the trailing slash that's added in the URL that contains the database name.

If the URL does not contain the database name, then it's like sqlalchemy tries to find the database having the same name as the user, so if you do not have a database named <user>, it fails to connect as well.

I'll see if I can come up with a patch that keeps the original idea of the author while allowing to connect to a specific database.

from stellar.

joshma avatar joshma commented on August 19, 2024

@pypingou thanks for the patch, that worked for me

from stellar.

vendion avatar vendion commented on August 19, 2024

I am also having problems getting it to work with a database that requires authentication to work. I have tried various formats:

postgresql://user:pass@localhost:5432/
postgresql://user:pass@localhast:5432/dbname
postgresql+psycopg2://user:pass@localhost:5432/
postgresql+psycopg2://user:pass@localhost:5432/dbname

No matter what though I get the same error:

Could not connect to database: postgresql+psycopg2://user:pass@localhost:5432/dbname
Make sure database process is running and try again.

Please enter the url for your database.

The server is running and I am able to connect to it with the psql command, and my app connects to it fine as well.

from stellar.

glennmartinez avatar glennmartinez commented on August 19, 2024

Can someone tell me what's going on here?

 lects/postgresql/psycopg2.py", line 422, in dbapi
 import psycopg2
  File "/Library/Python/2.7/site-packages/psycopg2/__init__.py", line 50, in <module>
  from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
 ImportError: dlopen(/Library/Python/2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded:       libssl.1.0.0.dylib
  Referenced from: /Library/Python/2.7/site-packages/psycopg2/_psycopg.so
 Reason: image not found

from stellar.

pypingou avatar pypingou commented on August 19, 2024

@vendion see #31

@glennmartinez you seem to be missing some libraries: libssl perhaps?

from stellar.

Teemu avatar Teemu commented on August 19, 2024

This was fixed by @pypingou's PR (thanks!).

from stellar.

Related Issues (20)

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.