https://infracost.io logo
#help
Title
# help
h

hundreds-activity-29799

07/14/2023, 6:52 PM
Hey guys, I am using your self-hosted API on my local machine. I was successful with loading the data and the GraphQL Playground shows results for my queries. But I am not quite sure how I could access the database with python for example. There are 2 docker containers running: cloud-pricing-api-api-1 (0.0.0.0:4000->4000/tcp) and cloud-pricing-api-postgres-1 (5432/tcp). I unsuccessfully tried to connect with the python postgres library psycopg2. Is that possible? I am not quite sure to which container to connect and with which parameters. Sadly, try and error resulted only in error ;-) Edit: And any tipps are much appreciated! If someone used a different library that code would also help me of course. For psycopg2 you need to specify: database="cloud-pricing", (also tried cloud-pricing-api-postgres-1) user="postgres", password="postgres", host="0.0.0.0", port="4000" (but also tried 5432) Thank you so much for your awesome work
l

little-author-61621

07/15/2023, 7:55 AM
Hi @hundreds-activity-29799. If you’re running docker-compose to launch the database, you will probably need to update the
docker-compose
file to expose the postgresql port. You can do this by adding something like:
Copy code
ports
    - 5444:5432
To the
postgres
service in that file. That will mean the DB is now available on port 5444 from your local host. Once that’s done you should be able to connect to it with the following settings:
Copy code
host: localhost
port: 5444
user: postgres
password: postgres
database: cloud_pricing
h

hundreds-activity-29799

07/15/2023, 11:20 AM
Of Course! Thank you so much. Is there a way to send you some coffee-money?
l

little-author-61621

07/15/2023, 2:24 PM
No problem. Thanks 🙏! We don't take any sponsorship, but appreciate any opportunity you have to spread the word about infracost.
3 Views