This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - Сущность «houses» - дома, обслуживаемые управляющей компанией. | |
| CREATE TABLE IF NOT EXISTS houses ( | |
| house_id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, -- Идентификатор дома. address TEXT NOT NULL, - Адрес дома. | |
| entrances_count INTEGER NOT NULL, | |
| -- Количество подьездов. | |
| floors_count INTEGER NOT NULL -- Количество этажей. | |
| KC | |
| - Сущность «apartments» - квартиры в обслуживаемых домах. | |
| CREATE TABLE IF NOT EXISTS apartments ( | |
| apartment_id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, — Идентификатор house_id INTEGER NOT NULL, -- Ссылка на дом. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| request_id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - Идентификатор заявки. request_number TEXT NOT NULL UNIQUE, -- Номер заявки. resident_id INTEGER NOT NULL, — Ссылка на жильца. | |
| apartment_id INTEGER NOT NULL, -- Ссылка на квартиру. | |
| created_at TIMESTAMP NOT NULL, — Дата и время создания заявки. problem_description TEXT NOT NULL, — Описание неисправности или обращения. status TEXT NOT NULL, -- Текущий статус заявки. | |
| FOREIGN KEY (resident_id) REFERENCES residents(resident_id), | |
| FOREIGN KEY (apartment_id) REFERENCES apartments(apartment_id) | |
| 【 | |
| -- Сущность «work logs» - журнал выполненых работ по заявкам жильцов. | |
| CREATE TABLE IF NOT EXISTS work_logs ( | |
| work_log id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, —- Идентификатор записи | |
| выполненной работы. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tkinter as tk | |
| from tkinter import ttk, messagebox, simpledialog | |
| import psycopg2 | |
| from psycopg2 import Error | |
| import datetime | |
| class PostgresViewer(tk.Tk): | |
| def __init__(self): | |
| super().__init__() | |
| self.title("Простой редактор PostgreSQL") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import streamlit as st | |
| import psycopg2 | |
| import pandas as pd | |
| from psycopg2.extras import RealDictCursor | |
| # ===================== НАСТРОЙКИ ===================== | |
| st.set_page_config(page_title="PostgreSQL Просмотрщик", layout="wide") | |
| st.title("🔌 Простой просмотрщик и редактор PostgreSQL") | |
| # Боковая панель — подключение к БД |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 1. Дома | |
| INSERT INTO houses (address, entrances_count, floors_count) VALUES | |
| ('г. Москва, ул. Ленина, д. 10', 3, 9), | |
| ('г. Москва, ул. Пушкина, д. 25', 4, 12), | |
| ('г. Москва, пр-т Мира, д. 45', 2, 5); | |
| -- 2. Квартиры | |
| INSERT INTO apartments (house_id, apartment_number, area, rooms_count) VALUES | |
| (1, '10', 65.50, 3), | |
| (1, '15', 42.00, 2), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tkinter as tk | |
| from tkinter import ttk, messagebox | |
| import psycopg2 | |
| from datetime import datetime | |
| # ==================== НАСТРОЙКИ ПОДКЛЮЧЕНИЯ ==================== | |
| DB_CONFIG = { | |
| "dbname": "your_database_name", # ← замени на своё | |
| "user": "postgres", # или твой пользователь | |
| "password": "your_password", # ← замени |