-
Notifications
You must be signed in to change notification settings - Fork 4
/
verify_conn.py
50 lines (26 loc) · 1.11 KB
/
verify_conn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import psycopg2
from dotenv import load_dotenv, find_dotenv
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
from psycopg2 import sql
load_dotenv()
############################################################################################################
'''Verify the credentials before running deployment. '''
############################################################################################################
connection = psycopg2.connect(user=os.environ.get('aws_db_user'),
password=os.environ.get('aws_db_password'),
host=os.environ.get('aws_db_host'),
port=os.environ.get('aws_db_port'))#,
#database=os.environ.get('db_name'))
connection.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
# Create the cursor.
cursor = connection.cursor()
print(connection)
#Q_create_DB = """
# CREATE DATABASE sautidb;
# """
#cursor.execute(sql.SQL("CREATE DATABASE sautidb"))
#cursor.execute(Q_create_DB)
#connection.commit()
cursor.close()
connection.close()