https://github.com/artek0chumak/privatedb_bot
Telegram bot for private use.
https://github.com/artek0chumak/privatedb_bot
python3 sql telegram-bot
Last synced: 9 months ago
JSON representation
Telegram bot for private use.
- Host: GitHub
- URL: https://github.com/artek0chumak/privatedb_bot
- Owner: artek0chumak
- License: mit
- Created: 2018-06-13T08:13:36.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-17T19:01:45.000Z (about 8 years ago)
- Last Synced: 2025-06-17T05:04:30.633Z (about 1 year ago)
- Topics: python3, sql, telegram-bot
- Language: Python
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PrivateDB_bot
Простой бот для работы с базой данных PostreSQL. Возможна работа только с одним пользователем. Настраивается в config.json. Команды для работы с базой данных находятся в файле commands.json.
## Используемые библиотеки
- [python 3.6](https://www.python.org/)
- [telebot](https://github.com/eternnoir/pyTelegramBotAPI)
- [py-postgresql](https://pypi.org/project/py-postgresql/)
## Запуск
Вместе с файлом bot.py должен находится файл config.json и commands.json! Ниже представлены их шаблоны.
```
python bot.py
```
#### Пример config.json
Server - настройки для поключения к sql серверу. Format - настройки представления данных в сообщении.
```json
{
"server" :
{
"token": "your_bot_token",
"user_id": "123456789",
"url": "url_to_db",
"port": "1234",
"login": "login",
"password": "password",
"name": "db_name"
}
,
"format" :
{
"float_point": 3,
"date_format": "ISO",
"timespec": "seconds",
"date_time_separator": " "
}
}
```
#### Пример commands.json
```json
{
"command_name": "command body in sql",
"insert": "insert into table values (30, {0})",
"show": "select * from table"
}
```
Аргументы к командам пишутся в формате [python string](https://docs.python.org/2/library/string.html)
## Пример использования бота
```
show
(1, 10)
(2, 20)
insert 100
('INSERT', 1)
show
(1, 10)
(2, 20)
(30, 100)
```