Skip to content

Commit

Permalink
Add: teste de conexão do python com postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffersonSenaa committed Dec 18, 2024
1 parent 3c10ece commit 46f155c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
psycopg2-binary==2.9.3
sqlalchemy==2.0.21
14 changes: 14 additions & 0 deletions velho-oeste/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from sqlalchemy import create_engine

def test_connection():
try:
# Formato de URL de conexão do SQLAlchemy
engine = create_engine('postgresql://velho_oeste_user:vopassword@velho-oeste-postgres:5432/velho_oeste_db')
connection = engine.connect()
print("Conexão bem-sucedida ao banco de dados!")
connection.close()
except Exception as e:
print(f"Erro na conexão: {e}")

if __name__ == "__main__":
test_connection()

0 comments on commit 46f155c

Please sign in to comment.