problems net
This commit is contained in:
parent
5cd649b741
commit
1e9422f836
25
app.py
25
app.py
|
|
@ -1,25 +1,22 @@
|
|||
import psycopg2
|
||||
|
||||
print('Can`t establish connection to database')
|
||||
|
||||
'''
|
||||
conn = psycopg2.connect(
|
||||
try:
|
||||
conn = psycopg2.connect(
|
||||
dbname="kolchin",
|
||||
user="kolchin",
|
||||
password="postgres",
|
||||
host="pg",
|
||||
port="5432"
|
||||
)
|
||||
)
|
||||
except:
|
||||
print('Can`t establish connection to database')
|
||||
#print(conn)
|
||||
|
||||
cursor = conn.cursor()
|
||||
|
||||
with conn.cursor() as curs:
|
||||
curs.execute(CREATE TABLE IF NOT EXISTS tablee(
|
||||
name varchar(10) NOT NULL,
|
||||
surname varchar,
|
||||
city varchar,
|
||||
age smallint
|
||||
);)
|
||||
cursor.execute('CREATE TABLE IF NOT EXISTS tablee(name varchar(10) NOT NULL,surname varchar,city varchar,age smallint);')
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
'''
|
||||
cursor.close() # закрываем курсор
|
||||
conn.close() # закрываем соединение
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,11 @@ services:
|
|||
restart: unless-stopped
|
||||
networks:
|
||||
- pg-net
|
||||
#ipv4_address: 192.168.100.2
|
||||
ports:
|
||||
- 10500:5432
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
test: ["CMD-SHELL", "pg_isready -U kolchin"]
|
||||
interval: 5s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
|
@ -29,23 +32,29 @@ services:
|
|||
restart: unless-stopped
|
||||
networks:
|
||||
- pg-net
|
||||
#ipv4_address: 192.168.100.3
|
||||
depends_on:
|
||||
pg:
|
||||
condition: service_healthy
|
||||
app:
|
||||
build:
|
||||
context: ./
|
||||
args:
|
||||
PYTHON_VERSION: "3.10"
|
||||
UID: 10002
|
||||
container_name: python-app
|
||||
networks:
|
||||
- pg-net
|
||||
#ipv4_address: 192.168.100.4
|
||||
depends_on:
|
||||
pg:
|
||||
condition: service_healthy
|
||||
# app:
|
||||
# build:
|
||||
# context: ./
|
||||
# args:
|
||||
# PYTHON_VERSION: "3.10"
|
||||
# UID: 10002
|
||||
# container_name: python-app
|
||||
# networks:
|
||||
# - pg-net
|
||||
# depends_on:
|
||||
# pg:
|
||||
# condition: service_healthy
|
||||
|
||||
volumes:
|
||||
pg-data:
|
||||
networks:
|
||||
pg-net:
|
||||
#driver: bridge
|
||||
#ipam:
|
||||
# config:
|
||||
# - subnet: 192.168.100.0/24
|
||||
# - gateway: 192.168.100.1
|
||||
|
|
|
|||
Loading…
Reference in New Issue