From df95910e42958ed176f136fe27f6da8564ece8ec Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Thu, 13 Mar 2025 15:09:27 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=20=D0=91=D0=94=20=D1=81=D0=BE=D1=85?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=D1=8F=D0=B5=D1=82=D1=81=D1=8F=20UTF-8=20?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B8,=20=D0=B2=D0=BC=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=BE=20`\u`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ README.md | 1 + app/__init__.py | 2 +- app/db.py | 10 +++++++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85e0eb3..a366c99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 2.1.0 + +- В БД сохраняется UTF-8 строки, вместо `\u` + ### 2.0.0 - переход с SQLite3 на PostgreSQL diff --git a/README.md b/README.md index 6464480..8a63a77 100644 --- a/README.md +++ b/README.md @@ -84,4 +84,5 @@ Enter confirmation code: 14628 - **Pyrogram** — Telegram клиент - **python-dotenv** — Работа с `.env` файлами - **loguru** — Логирование +- **psycopg2** — Работа с PostgreSQL - **black** — Форматирование кода diff --git a/app/__init__.py b/app/__init__.py index 6662b81..26c3f66 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,6 +1,6 @@ # Информация о программе __author__ = 'Alexander Popov' -__version__ = (2, 0, 0) +__version__ = (2, 1, 0) # Импорт модулей стандартной библиотеки from os import getenv diff --git a/app/db.py b/app/db.py index 8d9bc24..a42958e 100644 --- a/app/db.py +++ b/app/db.py @@ -50,7 +50,15 @@ class DataBase(object): table = 'donates' cur = self.conn.cursor() - cur.execute('INSERT INTO {table} ("data") VALUES (\'{data}\')'.format(table=table, data=json.dumps(data))) + cur.execute( + 'INSERT INTO {table} ("data") VALUES (\'{data}\')'.format( + table=table, + data=json.dumps( + data, + ensure_ascii=False, + ), + ) + ) self.commit() cur.close()