Setup App Database & connect to database
Last updated
Last updated
import psycopg
try:
conn = psycopg.connect("dbname=fastapi user=postgres password=Password1")
cursor = conn.cursor()
print("Database connection successful")
except Exception as error:
print("Connecting to database failed")
print("Error: ", error)while True:
try:
conn = psycopg.connect("dbname=fastapi user=postgres password=Password1")
cursor = conn.cursor()
print("Database connection successful")
break
except Exception as error:
print("Connecting to database failed")
print("Error: ", error)
time.sleep(2)