https://github.com/danex-exe/databaze
The Python module provides classes for simplified file management and synchronization. The `DataFile` class allows you to create, read, write, rename, and delete files, as well as get their information. It supports working with files in JSON format and with the ability to keep logs.
https://github.com/danex-exe/databaze
database file-database json-database
Last synced: 9 months ago
JSON representation
The Python module provides classes for simplified file management and synchronization. The `DataFile` class allows you to create, read, write, rename, and delete files, as well as get their information. It supports working with files in JSON format and with the ability to keep logs.
- Host: GitHub
- URL: https://github.com/danex-exe/databaze
- Owner: Danex-Exe
- Created: 2024-10-04T09:12:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-07T09:22:41.000Z (11 months ago)
- Last Synced: 2025-06-07T15:47:40.406Z (10 months ago)
- Topics: database, file-database, json-database
- Language: Python
- Homepage:
- Size: 48.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Usage
## DataFile(name, type, encode, path, logs, logger)
name - Название файла
type - Расширение файла (default - json)
encode - Кодировка файла (default - utf-8)
path - Путь до файла (default - .)
logs - Показывать/Скрывать логи (default - False)
logger - Логер (default - None)
.create() - создает файл и, при необходимости, создает папку
.read() - чтение файла (если файл - json, то автоматическое переобразование в словарь)
.write(data) - запись данных в файл (если файл - json, то автоматическое переобразование в строчку)
.delete() - удаление файла
.rename(new_name) - переименование файла
.info() - возвращает информацию о файле (родительская папка, путь, размер, название, дата последнего изменения)
## DataBaze(path, logs, logger)
path - путь до папки (default - .)
logs - Показывать/Скрывать логи (default - False)
logger - Логер (default - None)
.file(name, type, encode) - обьявляет файл
.delete() - удаляет все файлы в базе данных
# Application
```python
from DataBaze import DataBaze
DATABAZE = DataBaze()
CONFIG_FILE = DATABAZE.file('config')
CONFIG_FILE.create() # if not created
data = {
"users": ["User1", "User2"],
"admins": ["User1"]
}
data_file.write(data)
print(data_file.read()['admins']) # ["User1"]
```
```js
const { DataBaze } = require('./DataBaze');
async function main() {
const db = new DataBaze('my-data');
const file = db.file('config');
// Создание файла
await file.create({ version: 1.0 });
// Чтение файла
const data = await file.read();
console.log(data);
// Обновление данных
await file.write({ ...data, updated: new Date() });
// Получение информации о файле
const info = await file.info();
console.log(info);
// Удаление базы данных
await db.delete();
}
main();
```