final
This commit is contained in:
parent
a5a70e3113
commit
2181f5f7fd
9
app.py
9
app.py
|
|
@ -14,9 +14,14 @@ except:
|
|||
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute('CREATE TABLE IF NOT EXISTS tablee(name varchar(10) NOT NULL,surname varchar,city varchar,age smallint);')
|
||||
cursor.execute('select max(age) as max_age, min(age) as min_age from test_table where length(name)<6;')
|
||||
result = cursor.fetchall()
|
||||
|
||||
|
||||
print(f'Максимальный возраст для имен, длина которых меньше 6 символов: {result[0][0]}')
|
||||
print(f'Минимальный возраст для имен, длина которых меньше 6 символов: {result[0][1]}')
|
||||
|
||||
|
||||
conn.commit()
|
||||
cursor.close() # закрываем курсор
|
||||
conn.close() # закрываем соединение
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
--create database test_db;
|
||||
--create user test_user with encrypted password '123';
|
||||
--grant all privileges on database test_db to test_user;
|
||||
CREATE TABLE IF NOT EXISTS test_table(
|
||||
--id INT PRIMARY KEY,
|
||||
name varchar(10) NOT NULL,
|
||||
name varchar(10) NOT NULL CONSTRAINT dlina_name CHECK (char_length(name) between 4 and 10),
|
||||
surname varchar,
|
||||
city varchar,
|
||||
age smallint
|
||||
age smallint CONSTRAINT positive_age CHECK (age > 0 and age<=150)
|
||||
);
|
||||
|
||||
insert into test_table (name, surname, city, age)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ services:
|
|||
restart: unless-stopped
|
||||
networks:
|
||||
- pg-net
|
||||
#ipv4_address: 192.168.100.2
|
||||
ports:
|
||||
- 10500:5432
|
||||
healthcheck:
|
||||
|
|
@ -21,21 +20,21 @@ services:
|
|||
interval: 5s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
pgadmin:
|
||||
image: dpage/pgadmin4:8.12.0
|
||||
container_name: pgadmin_new
|
||||
environment:
|
||||
PGADMIN_DEFAULT_EMAIL: user@example.com
|
||||
PGADMIN_DEFAULT_PASSWORD: postgres
|
||||
ports:
|
||||
- 10501:80
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- pg-net
|
||||
#ipv4_address: 192.168.100.3
|
||||
depends_on:
|
||||
pg:
|
||||
condition: service_healthy
|
||||
# для ручного мониторинга
|
||||
# pgadmin:
|
||||
# image: dpage/pgadmin4:8.12.0
|
||||
# container_name: pgadmin_new
|
||||
# environment:
|
||||
# PGADMIN_DEFAULT_EMAIL: user@example.com
|
||||
# PGADMIN_DEFAULT_PASSWORD: postgres
|
||||
# ports:
|
||||
# - 10501:80
|
||||
# restart: unless-stopped
|
||||
# networks:
|
||||
# - pg-net
|
||||
# depends_on:
|
||||
# pg:
|
||||
# condition: service_healthy
|
||||
app:
|
||||
build:
|
||||
context: ./
|
||||
|
|
@ -45,7 +44,6 @@ services:
|
|||
container_name: python-app
|
||||
networks:
|
||||
- pg-net
|
||||
#ipv4_address: 192.168.100.4
|
||||
depends_on:
|
||||
pg:
|
||||
condition: service_healthy
|
||||
|
|
@ -54,7 +52,3 @@ volumes:
|
|||
networks:
|
||||
pg-net:
|
||||
driver: bridge
|
||||
#ipam:
|
||||
# config:
|
||||
# - subnet: 192.168.100.0/24
|
||||
# - gateway: 192.168.100.1
|
||||
|
|
|
|||
Loading…
Reference in New Issue