fief-dev / fief

Users and authentication management SaaS
https://www.fief.dev
Other
538 stars 44 forks source link

"Connection to your database" #77

Closed yomuevans closed 2 years ago

yomuevans commented 2 years ago

Hi, so am trying to follow the instructions in the link https://docs.fief.dev/going-further/byod/#setup-your-database, in my own http://localhost:8000/admin/create-workspace/step3

Database type: PostgreSQL
Host: localhost
Port:5432
Username:XXXX
Password:XXXX
Database name:XXXX
SSL mode: Prefer

(I did not actually use XXX) I have my own database setup and working(I use pgadmin), but whenever i check connection.

Can't connect to the database: (psycopg2.OperationalError) could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? (Background on this error at: https://sqlalche.me/e/14/e3q8)

yomuevans commented 2 years ago

this simple program works

import time import psycopg2 import sys

def Save_db(): while True: try: conn = psycopg2.connect(host="localhost", user="XXX", password="XXX", database="XXX") conn.autocommit = True cursor = conn.cursor() print("database connection was successfully")

        cursor.execute('GRANT ALL PRIVILEGES ON DATABASE "XXX" TO XXX;')
        table_name = "Ephemeris"
        # my simple attempt to update table
        cursor.execute("DROP TABLE IF EXISTS {};".format(table_name))
        cursor.execute('CREATE table {} ()'.format(table_name))
        break
    except Exception as error:
        print("Connecting to database failed")
        print("Error: ", error)
        time.sleep(10)

if name == "main": Save_db()