Metadata-Version: 2.4
Name: ossdbutil
Version: 1.0.1
Summary: OSS + AnalyticDB for PostgreSQL file sync tool with metadata (adbpg_filestore SDK)
Author: Alibaba Cloud AnalyticDB for PostgreSQL
License: Apache-2.0
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Database
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: oss2<3,>=2.15.0
Requires-Dist: psycopg2-binary<3,>=2.8.0
Requires-Dist: PyYAML<7,>=5.1
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# ossdbutil

`ossdbutil` 是 AnalyticDB for PostgreSQL `adbpg_filestore` 扩展配套的 Python SDK 与命令行工具：文件存放在 OSS，元数据（目录、标签、租户、属主）自动同步到数据库的 `pg_directory_table` 目录表，可直接用 SQL 查询与管理。

## 安装

```bash
python3 -m pip install ossdbutil
ossdbutil --version
```

要求 Python 3.6 及以上、pip 19.3 及以上（可先执行 `python3 -m pip install -U pip`）；目标实例需已执行 `CREATE EXTENSION adbpg_filestore;`。

## 快速开始

```bash
ossdbutil init          # 生成 ~/.ossdbutil/config.yaml，填写 OSS 与数据库连接信息
ossdbutil upload ./report.csv /reports
```

```python
from ossdbutil import OSSDBClient

client = OSSDBClient.from_config('~/.ossdbutil/config.yaml')
with open('report.csv', 'rb') as f:
    client.put_object('reports/report.csv', f)

for obj in client.list_objects(prefix='reports/'):
    print(obj['file_name'], obj['size'])
```

## 命令行子命令

| 子命令 | 说明 |
|---|---|
| `init` | 生成配置文件 |
| `upload` / `download` | 上传、下载文件或目录 |
| `copy` | 复制 OSS 对象 |
| `multipart-upload` | 分片上传大文件 |
| `init-from-oss` | 将 OSS 上已有对象同步到元数据表 |
| `delete` | 删除文件及其元数据 |
| `grant` | 管理文件属主 |

使用 `ossdbutil <子命令> --help` 查看参数。

## License

Apache-2.0
