Metadata-Version: 2.4
Name: funbase
Version: 0.1.1
Summary: FunBase: encrypted file-based database with .fb extension
Author-email: Nite017 <nite27845@yandex.ru>
License: MIT License
        
        Copyright (c) 2026 Nite017
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: VK, https://vk.com/Nite017
Project-URL: Telegram, https://t.me/niteburn
Project-URL: FunBaseEditor, https://github.com/Nite017/FunBaseEditor
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography>=3.4
Dynamic: license-file

# FunBase

- RU: FunBase — это любительский проект, разработанный Nite017, представляющий удобную базу данных с расширением FB
- EN: FunBase is a hobby project developed by Nite017, providing a user-friendly database with the FB extension

# В последней версии 1.1 | In last Update:

### FunBase Editor
![Превью приложения](images/p2.png)
- RU: Изменяй свои fb файлы в удобном приложении! Скачать можно по ссылке
https://github.com/Nite017/FunBaseEditor
- EN: Change your FB files in the app! Download here
https://github.com/Nite017/FunBaseEditor
## Возможности | Features

- `create_table(table_name)` — создать таблицу / create a table.
- `insert(table_name, record)` — добавить запись / insert a record.
- `select_all(table_name)` — получить все записи / get all records.
- `Update(table_name, 'SET x = (?) WHERE y = (?)', value, where_value, count)` — обновление по строковому шаблону / update with SQL-like syntax.
- `Update_int(table_name, 'SET x = (?) WHERE y > (?)', value, where_value, count)` — числовое обновление / numeric update.
- `remove(table_name, '(?) WHERE y = (?)', value, where_value, count)` — удаление по шаблону / remove by template.
- `search(table_name, phrase)` — поиск по фразе / search by phrase.
- `select_random(table_name, column, count)` — случайные значения колонки / random values from a column.
- `print_random(table_name, count)` — случайные записи / random records.
- `delete_table(table_name)` — удалить таблицу / delete a table.
- `tables()` — список таблиц / list tables.

## Правила Update | Update rules

```python
db.Update("users", "SET name = (?) WHERE id = (?)", "Alice", 1, 0)
```

RU: Последний аргумент — количество обновлений. `0` значит обновить все подходящие записи.
EN: The last argument is the number of updates. `0` means update all matching records.

## Правила remove | Remove rules

```python
db.remove("users", "(?) WHERE age = (?)", 25, 2)
```

RU: Последний аргумент — количество удалений. `0` значит удалить все подходящие записи.
EN: The last argument is the number of deletions. `0` means remove all matching records.

## Правила Update_int | Update_int rules

Поддерживаются / Supported:
- `=`
- `==`
- `!=`
- `>`
- `<`
- `>=`
- `<=`

```python
db.Update_int("users", "SET age = (?) WHERE age > (?)", 40, 25, 1)
```

## Пример | Example

```python
from funbase import FunBase
import os

DB_FILE = "demo_v5.fb"

if os.path.exists(DB_FILE):
    os.remove(DB_FILE)

db = FunBase(DB_FILE)

db.create_table("users")
db.insert("users", {"id": 1, "name": "Alice", "age": 25})
db.insert("users", {"id": 2, "name": "Bob", "age": 30})
db.insert("users", {"id": 3, "name": "Charlie", "age": 18})
db.insert("users", {"id": 4, "name": "Diana", "age": 30})

print("Before:")
for row in db.select_all("users"):
    print(row)

print("\nUpdate:")
db.Update("users", "SET name = (?) WHERE id = (?)", "Bobby", 2, 1)

print("\nRemove:")
db.remove("users", "WHERE age = (?)", 30, 1)

print("\nSearch 'Ali':")
print(db.search("users", "Ali"))

print("\nRandom ids:")
print(db.select_random("users", "id", 2))

print("\nRandom rows:")
db.print_random("users", 2)

print("\nAfter:")
for row in db.select_all("users"):
    print(row)
```


## Пример | Example

```python
from funbase import FunBase

db = FunBase("demo_v5.fb")

print("RU: Таблицы | EN: Tables:", db.tables())

print("\nRU: Поиск по фразе 'Bob' | EN: Search phrase 'Bob':")
print(db.search("users", "Bob"))

print("\nRU: Случайные id | EN: Random ids:")
print(db.select_random("users", "id", 2))

print("\nRU: Случайные записи | EN: Random rows:")
db.print_random("users", 2)

print("\nRU: Все данные | EN: All data:")
for table in db.tables():
    print(f"\n=== {table} ===")
    for row in db.select_all(table):
        print(row)
```
## Ошибки | Errors

RU: Сообщения об ошибках выводятся на русском и английском.
EN: Error messages are shown in both Russian and English.
