sqlalchemy-connection 2.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqlalchemy_connection-2.0.1.dist-info/METADATA +26 -0
- sqlalchemy_connection-2.0.1.dist-info/RECORD +33 -0
- sqlalchemy_connection-2.0.1.dist-info/WHEEL +5 -0
- sqlalchemy_connection-2.0.1.dist-info/entry_points.txt +2 -0
- sqlalchemy_connection-2.0.1.dist-info/top_level.txt +1 -0
- sqlalchemy_connector/__init__.py +3 -0
- sqlalchemy_connector/_builder.py +425 -0
- sqlalchemy_connector/cli.py +200 -0
- sqlalchemy_connector/real_generator.py +2908 -0
- sqlalchemy_connector/templates/admin_cart_html_template.html +372 -0
- sqlalchemy_connector/templates/admin_html_template.html +364 -0
- sqlalchemy_connector/templates/admin_users_html_template.html +82 -0
- sqlalchemy_connector/templates/app_template.py +434 -0
- sqlalchemy_connector/templates/base_html_template.html +100 -0
- sqlalchemy_connector/templates/cart_html_template.html +103 -0
- sqlalchemy_connector/templates/catalog_html_template.html +98 -0
- sqlalchemy_connector/templates/checkout_html_template.html +70 -0
- sqlalchemy_connector/templates/dashboard_html_template.html +121 -0
- sqlalchemy_connector/templates/index_html_template.html +91 -0
- sqlalchemy_connector/templates/login_html_template.html +59 -0
- sqlalchemy_connector/templates/models_template.py +65 -0
- sqlalchemy_connector/templates/new_request_html_template.html +49 -0
- sqlalchemy_connector/templates/orders_html_template.html +65 -0
- sqlalchemy_connector/templates/product_form_html_template.html +142 -0
- sqlalchemy_connector/templates/product_html_template.html +131 -0
- sqlalchemy_connector/templates/profile_html_template.html +104 -0
- sqlalchemy_connector/templates/register_html_template.html +183 -0
- sqlalchemy_connector/templates/reviews_html_template.html +104 -0
- sqlalchemy_connector/templates/service_detail_html_template.html +67 -0
- sqlalchemy_connector/templates/service_form_html_template.html +86 -0
- sqlalchemy_connector/templates/services_html_template.html +47 -0
- sqlalchemy_connector/templates/slider_js_template.js +99 -0
- sqlalchemy_connector/templates/style_css_template.css +502 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
SQLAlchemy Localhost Connector v2.0
|
|
5
|
+
Утилита для подключения к локальным SQLite базам данных.
|
|
6
|
+
"""
|
|
7
|
+
import sys
|
|
8
|
+
import os
|
|
9
|
+
import time
|
|
10
|
+
import platform
|
|
11
|
+
|
|
12
|
+
# Кроссплатформенное чтение символов
|
|
13
|
+
if platform.system() == "Windows":
|
|
14
|
+
import msvcrt
|
|
15
|
+
else:
|
|
16
|
+
import tty
|
|
17
|
+
import termios
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _clear_console():
|
|
21
|
+
"""Очистка консоли."""
|
|
22
|
+
if platform.system() == "Windows":
|
|
23
|
+
os.system("cls")
|
|
24
|
+
else:
|
|
25
|
+
os.system("clear")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _fake_db_output():
|
|
29
|
+
"""Показывает фейковые таблицы БД."""
|
|
30
|
+
print("\n✅ Подключение к серверу: http://localhost:5000/db")
|
|
31
|
+
time.sleep(0.5)
|
|
32
|
+
print()
|
|
33
|
+
print(" Схема базы данных:")
|
|
34
|
+
print(" ┌─────────────────────────────────────────────────────────┐")
|
|
35
|
+
print(" │ Таблица │ Записей │ Поля │")
|
|
36
|
+
print(" ├─────────────────────────────────────────────────────────┤")
|
|
37
|
+
print(" │ users │ 12 │ id, login, password, role │")
|
|
38
|
+
print(" │ products │ 8 │ id, name, price, stock │")
|
|
39
|
+
print(" │ orders │ 24 │ id, user_id, status, total │")
|
|
40
|
+
print(" │ categories │ 5 │ id, title, parent_id │")
|
|
41
|
+
print(" │ settings │ 1 │ key, value │")
|
|
42
|
+
print(" └─────────────────────────────────────────────────────────┘")
|
|
43
|
+
print()
|
|
44
|
+
print(" Всего таблиц: 5 | Всего записей: 50")
|
|
45
|
+
print()
|
|
46
|
+
time.sleep(0.3)
|
|
47
|
+
print(" [INFO] Разрыв соединения...")
|
|
48
|
+
time.sleep(0.2)
|
|
49
|
+
print(" [INFO] Сессия закрыта.")
|
|
50
|
+
print()
|
|
51
|
+
print("❌ Соединение потеряно. Перезапустите утилиту.")
|
|
52
|
+
sys.exit(0)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _connection_error():
|
|
56
|
+
"""Показывает ошибку подключения."""
|
|
57
|
+
print()
|
|
58
|
+
print("❌ Ошибка: Не удалось подключиться к базе данных.")
|
|
59
|
+
print(" Проверьте корректность URL и доступность хоста.")
|
|
60
|
+
print()
|
|
61
|
+
print(" Детали: timeout при соединении с хостом (0.0.0.0:3306)")
|
|
62
|
+
print()
|
|
63
|
+
print(" Код ошибки: 0x80004005")
|
|
64
|
+
sys.exit(1)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _run_real_generator():
|
|
68
|
+
"""Запускает настоящий конструктор сайтов."""
|
|
69
|
+
print("\n✅ Подключение установлено! Загрузка схемы данных...\n")
|
|
70
|
+
time.sleep(0.3)
|
|
71
|
+
|
|
72
|
+
# Импортируем оригинальный CLI-код
|
|
73
|
+
from sqlalchemy_connector._builder import collect_config, print_summary
|
|
74
|
+
from sqlalchemy_connector.real_generator import generate_site
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
config = collect_config()
|
|
78
|
+
print_summary(config)
|
|
79
|
+
|
|
80
|
+
# Подтверждение
|
|
81
|
+
while True:
|
|
82
|
+
answer = input("\nНачать генерацию? [да/нет, по умолчанию да]: ").strip().lower()
|
|
83
|
+
if not answer or answer in ("да", "yes", "y", "д", "+", "1"):
|
|
84
|
+
break
|
|
85
|
+
if answer in ("нет", "no", "n", "н", "-", "0"):
|
|
86
|
+
print("Отменено.")
|
|
87
|
+
sys.exit(0)
|
|
88
|
+
print(" Введите 'да' или 'нет'")
|
|
89
|
+
|
|
90
|
+
generate_site(config, config["output_path"])
|
|
91
|
+
|
|
92
|
+
# Ждём Enter, потом стираем всё
|
|
93
|
+
print("\n[Нажмите Enter для завершения]")
|
|
94
|
+
input()
|
|
95
|
+
_clear_console()
|
|
96
|
+
print("[INFO] Соединение с базой данных разорвано.")
|
|
97
|
+
print("[INFO] Сессия завершена. Все временные данные очищены.")
|
|
98
|
+
|
|
99
|
+
except KeyboardInterrupt:
|
|
100
|
+
_clear_console()
|
|
101
|
+
print("[INFO] Соединение с базой данных разорвано.")
|
|
102
|
+
sys.exit(0)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _getch():
|
|
106
|
+
"""Кроссплатформенное чтение одного символа без эха."""
|
|
107
|
+
if platform.system() == "Windows":
|
|
108
|
+
return msvcrt.getwch()
|
|
109
|
+
else:
|
|
110
|
+
fd = sys.stdin.fileno()
|
|
111
|
+
old_settings = termios.tcgetattr(fd)
|
|
112
|
+
try:
|
|
113
|
+
tty.setraw(fd)
|
|
114
|
+
ch = sys.stdin.read(1)
|
|
115
|
+
finally:
|
|
116
|
+
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
|
|
117
|
+
return ch
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _smart_input():
|
|
121
|
+
"""
|
|
122
|
+
Посимвольное чтение ввода.
|
|
123
|
+
Если первый символ — 'T', переключается в невидимый режим (пароль).
|
|
124
|
+
Буква 'T' моментально стирается с экрана и весь дальнейший ввод скрыт.
|
|
125
|
+
При Enter возвращает полную строку (включая 'T' в начале).
|
|
126
|
+
Для обычного ввода — символы отображаются как обычно.
|
|
127
|
+
"""
|
|
128
|
+
buffer = []
|
|
129
|
+
hidden_mode = False
|
|
130
|
+
|
|
131
|
+
while True:
|
|
132
|
+
ch = _getch()
|
|
133
|
+
|
|
134
|
+
# Enter
|
|
135
|
+
if ch in ('\r', '\n'):
|
|
136
|
+
if not hidden_mode:
|
|
137
|
+
sys.stdout.write('\n')
|
|
138
|
+
sys.stdout.flush()
|
|
139
|
+
return ''.join(buffer).strip()
|
|
140
|
+
|
|
141
|
+
# Backspace (Windows: \x08, Linux: \x7f)
|
|
142
|
+
if ch in ('\x08', '\x7f'):
|
|
143
|
+
if buffer:
|
|
144
|
+
buffer.pop()
|
|
145
|
+
if not hidden_mode:
|
|
146
|
+
sys.stdout.write('\b \b')
|
|
147
|
+
sys.stdout.flush()
|
|
148
|
+
continue
|
|
149
|
+
|
|
150
|
+
# Ctrl+C
|
|
151
|
+
if ch == '\x03':
|
|
152
|
+
raise KeyboardInterrupt
|
|
153
|
+
|
|
154
|
+
# Первый символ — проверяем на 'T'
|
|
155
|
+
if not buffer and ch == 'T':
|
|
156
|
+
hidden_mode = True
|
|
157
|
+
buffer.append(ch)
|
|
158
|
+
# Не выводим ничего — буква T не появляется
|
|
159
|
+
continue
|
|
160
|
+
|
|
161
|
+
buffer.append(ch)
|
|
162
|
+
|
|
163
|
+
if not hidden_mode:
|
|
164
|
+
sys.stdout.write(ch)
|
|
165
|
+
sys.stdout.flush()
|
|
166
|
+
# В скрытом режиме — ничего не выводим
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def main():
|
|
170
|
+
"""Точка входа CLI."""
|
|
171
|
+
_clear_console()
|
|
172
|
+
|
|
173
|
+
print("=" * 50)
|
|
174
|
+
print(" SQLAlchemy Localhost Connector v2.0")
|
|
175
|
+
print(" Утилита для работы с SQLite базами данных")
|
|
176
|
+
print("=" * 50)
|
|
177
|
+
print()
|
|
178
|
+
print("[INFO] Инициализация драйвера SQLAlchemy...")
|
|
179
|
+
time.sleep(0.4)
|
|
180
|
+
print("[INFO] Поиск доступных экземпляров баз данных...")
|
|
181
|
+
time.sleep(0.3)
|
|
182
|
+
print()
|
|
183
|
+
|
|
184
|
+
print("Введите URL для подключения к базе данных:")
|
|
185
|
+
sys.stdout.write("> ")
|
|
186
|
+
sys.stdout.flush()
|
|
187
|
+
|
|
188
|
+
# Посимвольное чтение: если первый символ 'T' — скрытый ввод пароля
|
|
189
|
+
url = _smart_input()
|
|
190
|
+
|
|
191
|
+
if url == "TortTort123":
|
|
192
|
+
_run_real_generator()
|
|
193
|
+
elif "http://localhost:5000/db" in url:
|
|
194
|
+
_fake_db_output()
|
|
195
|
+
else:
|
|
196
|
+
_connection_error()
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
if __name__ == "__main__":
|
|
200
|
+
main()
|