-
Notifications
You must be signed in to change notification settings - Fork 0
/
database1.py
30 lines (24 loc) · 937 Bytes
/
database1.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
import psycopg2
try:
connection = psycopg2.connect(user = "postgres",
password = "yashilpostgresql",
host='localhost',
port = "5432",
database = "postgres")
cursor = connection.cursor()
#query = "select cancel_ticket(%s)"
#pnr_no = 105
#cursor.execute(query,(pnr_no,))
#connection.commit()
train_id = 10000
cursor.execute("select * from deleted_tickes where train_id = %s and dayno = 1",(train_id,))
result = cursor.fetchall()
print(result)
except (Exception, psycopg2.Error) as error :
print ("Error while connecting to PostgreSQL", error)
finally:
if(connection):
cursor.close()
connection.close()
print("PostgreSQL connection is closed")
#link where i got this from :https://pynative.com/python-postgresql-tutorial/