This commit is contained in:
sanek 2024-12-12 20:04:42 +00:00
parent a5a70e3113
commit 2181f5f7fd
3 changed files with 24 additions and 28 deletions

9
app.py
View File

@ -14,9 +14,14 @@ except:
cursor = conn.cursor() 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() # закрываем курсор cursor.close() # закрываем курсор
conn.close() # закрываем соединение conn.close() # закрываем соединение

View File

@ -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( CREATE TABLE IF NOT EXISTS test_table(
--id INT PRIMARY KEY, --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, surname varchar,
city varchar, city varchar,
age smallint age smallint CONSTRAINT positive_age CHECK (age > 0 and age<=150)
); );
insert into test_table (name, surname, city, age) insert into test_table (name, surname, city, age)

View File

@ -13,7 +13,6 @@ services:
restart: unless-stopped restart: unless-stopped
networks: networks:
- pg-net - pg-net
#ipv4_address: 192.168.100.2
ports: ports:
- 10500:5432 - 10500:5432
healthcheck: healthcheck:
@ -21,21 +20,21 @@ services:
interval: 5s interval: 5s
timeout: 10s timeout: 10s
retries: 3 retries: 3
pgadmin: # для ручного мониторинга
image: dpage/pgadmin4:8.12.0 # pgadmin:
container_name: pgadmin_new # image: dpage/pgadmin4:8.12.0
environment: # container_name: pgadmin_new
PGADMIN_DEFAULT_EMAIL: user@example.com # environment:
PGADMIN_DEFAULT_PASSWORD: postgres # PGADMIN_DEFAULT_EMAIL: user@example.com
ports: # PGADMIN_DEFAULT_PASSWORD: postgres
- 10501:80 # ports:
restart: unless-stopped # - 10501:80
networks: # restart: unless-stopped
- pg-net # networks:
#ipv4_address: 192.168.100.3 # - pg-net
depends_on: # depends_on:
pg: # pg:
condition: service_healthy # condition: service_healthy
app: app:
build: build:
context: ./ context: ./
@ -45,7 +44,6 @@ services:
container_name: python-app container_name: python-app
networks: networks:
- pg-net - pg-net
#ipv4_address: 192.168.100.4
depends_on: depends_on:
pg: pg:
condition: service_healthy condition: service_healthy
@ -54,7 +52,3 @@ volumes:
networks: networks:
pg-net: pg-net:
driver: bridge driver: bridge
#ipam:
# config:
# - subnet: 192.168.100.0/24
# - gateway: 192.168.100.1