Metadata-Version: 2.4
Name: jiaofu-dbview
Version: 0.2.9
Summary: Shared database access layer for Jiaofu AgentOS services
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: pymysql>=1.1.1

# jiaofu-dbview

Shared database access package for Jiaofu AgentOS services.

The distribution name is `jiaofu-dbview`; the Python import name remains
`dbview`, so existing application imports do not need to change:

```python
from dbview.pys.dbview_dataset import DbViewDataset
```

Both the OceanBase and SQLite SQL definitions are included in the wheel.
Runtime SQLite database files are deliberately not packaged.

Configuration is supplied explicitly by the caller; this package does not read
service config files or environment variables:

```python
from dbview import OceanBaseConfig, SQLiteConfig
from dbview.pys.dbview_dataset import DbViewDataset

oceanbase = DbViewDataset(
    "oceanbase",
    OceanBaseConfig(
        host="db.example.internal",
        port=2880,
        user="user",
        password="secret",
        database="tikumis",
    ),
)

sqlite = DbViewDataset("sqlite", SQLiteConfig(path="/data/sessions.db"))
```

Count user messages with and without `AUTO_FLASH` in one database query:

```python
stats = sqlite.count_user_message_stats(cuid="cuid-1", uid="uid-1")
# Example: {"total": 2, "all_total": 3}
history_count = stats["total"]          # Excludes messages starting with [AUTO_FLASH].
has_chat_history = stats["all_total"] > 0  # Includes those messages.
```

The method supports both backends and uses the same identity scope as the existing
message counts: `cuid` is always required; a nonempty `uid` other than `"0"` also
filters by `uid`. Assistant and tool messages are excluded from both counts.
No matching user messages returns `{"total": 0, "all_total": 0}`. Existing
`count_messages()` and `count_real_user_messages()` keep their original behavior.
