Skip to content

Commit 767c1e7

Browse files
author
ADOT Patch workflow
committed
remove debug information
1 parent 7bfd827 commit 767c1e7

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

contract-tests/images/applications/psychopg2/postgreSQL-docker.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ services:
88
POSTGRES_PASSWORD: password
99
ports:
1010
- "5432:5432"
11+
networks:
12+
- db-network
13+
14+
networks:
15+
db-network:
16+
driver: bridge

contract-tests/images/applications/psychopg2/psychopg2-database.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,31 @@
1212
_PASSWORD = 'password'
1313
_HOST = 'localhost'
1414

15-
class RequestHandler(BaseHTTPRequestHandler):
16-
17-
def __init__(self, request, client_address, server):
18-
print("psychopg init")
19-
super().__init__(request, client_address, server)
20-
self.prepare_database()
2115

22-
def prepare_database(self) -> None:
23-
24-
conn = psycopg2.connect(dbname=_DBNAME, user=_USER, password=_PASSWORD, host=_HOST)
16+
def prepare_database() -> None:
17+
conn = psycopg2.connect(dbname=_DBNAME, user=_USER, password=_PASSWORD, host=_HOST)
2518

26-
print("db connected")
19+
print("db connected")
2720

28-
cur = conn.cursor()
21+
cur = conn.cursor()
2922

30-
cur.execute("""
23+
cur.execute("""
3124
CREATE TEMPORARY TABLE test_table (
3225
id SERIAL PRIMARY KEY,
3326
name TEXT NOT NULL
3427
)
3528
""")
3629

37-
cur.execute("INSERT INTO test_table (name) VALUES (%s)", ("Alice",))
38-
cur.execute("INSERT INTO test_table (name) VALUES (%s)", ("Bob",))
30+
cur.execute("INSERT INTO test_table (name) VALUES (%s)", ("Alice",))
31+
cur.execute("INSERT INTO test_table (name) VALUES (%s)", ("Bob",))
3932

40-
conn.commit()
33+
conn.commit()
4134

42-
cur.close()
43-
conn.close()
35+
cur.close()
36+
conn.close()
4437

38+
39+
class RequestHandler(BaseHTTPRequestHandler):
4540
@override
4641
# pylint: disable=invalid-name
4742
def do_GET(self):
@@ -66,7 +61,9 @@ def handle_request(self):
6661
conn.close()
6762
self.send_response(200, "success")
6863

69-
def main()->None:
64+
65+
def main() -> None:
66+
prepare_database()
7067
server_address: Tuple[str, int] = ("0.0.0.0", _PORT)
7168
request_handler_class: type = RequestHandler
7269
requests_server: ThreadingHTTPServer = ThreadingHTTPServer(server_address, request_handler_class)
@@ -76,5 +73,6 @@ def main()->None:
7673
print("Psychopg2-Ready")
7774
server_thread.join()
7875

76+
7977
if __name__ == "__main__":
8078
main()

0 commit comments

Comments
 (0)