From d0fb0e5c7adcedd43e2f9819a034df9e3ee5bf95 Mon Sep 17 00:00:00 2001 From: Bibo Hao Date: Wed, 10 Sep 2025 17:22:04 +0000 Subject: [PATCH 1/2] update README and comments --- README.md | 21 ++++++++++++++------- src/aloha/db/duckdb.py | 23 ++++++++++------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 511972c..623c10f 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,30 @@ # Aloha! +## What is it? + +`aloha` is a versatile Python utility package for building microservices. + [![License](https://img.shields.io/github/license/QPod/aloha)](https://github.com/QPod/aloha/blob/main/LICENSE) [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/QPod/aloha-python/pip.yml?branch=main)](https://github.com/QPod/aloha-python/actions) -[![Join the Gitter Chat](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/QPod/) -[![PyPI version](https://img.shields.io/pypi/v/aloha)](https://pypi.python.org/pypi/aloha/) -[![PyPI Downloads](https://img.shields.io/pypi/dm/aloha)](https://pepy.tech/badge/aloha/) [![Code Activity](https://img.shields.io/github/commit-activity/m/QPod/aloha)](https://github.com/QPod/aloha/pulse) [![Recent Code Update](https://img.shields.io/github/last-commit/QPod/docker-images.svg)](https://github.com/QPod/aloha/stargazers) -Please generously STAR★ our project or donate to us! [![GitHub Starts](https://img.shields.io/github/stars/QPod/aloha.svg?label=Stars&style=social)](https://github.com/QPod/aloha/stargazers) +[![PyPI version](https://img.shields.io/pypi/v/aloha)](https://pypi.python.org/pypi/aloha/) +[![PyPI Downloads](https://img.shields.io/pypi/dm/aloha)](https://pepy.tech/badge/aloha/) + +--- + +Please generously STAR★ our project or donate to us! +[![GitHub Starts](https://img.shields.io/github/stars/QPod/aloha.svg?label=Stars&style=social)](https://github.com/QPod/aloha/stargazers) [![Donate-PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg)](https://paypal.me/haobibo) [![Donate-AliPay](https://img.shields.io/badge/Donate-Alipay-blue.svg)](https://raw.githubusercontent.com/wiki/haobibo/resources/img/Donate-AliPay.png) [![Donate-WeChat](https://img.shields.io/badge/Donate-WeChat-green.svg)](https://raw.githubusercontent.com/wiki/haobibo/resources/img/Donate-WeChat.png) -## What is it? +- For documentation, visit: [📚 Document & 中文文档](https://aloha-python.readthedocs.io/) -`aloha` is a versatile Python utility package for building microservices. +- For questions, try DeepWiki: [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/QPod/aloha-python) -[📚 Document & 中文文档](https://aloha-python.readthedocs.io/) +- To contribute or talk to a human: [![Open an Issue on GitHub](https://img.shields.io/github/issues/QPod/aloha-python)](https://github.com/QPod/aloha-python/issues) [![Join the Discord Chat](https://img.shields.io/badge/Discuss_on-Discord-green)](https://discord.gg/kHUzgQxgbJ) ## Getting started diff --git a/src/aloha/db/duckdb.py b/src/aloha/db/duckdb.py index 7935291..9fada3d 100644 --- a/src/aloha/db/duckdb.py +++ b/src/aloha/db/duckdb.py @@ -12,13 +12,12 @@ class DuckOperator: def __init__(self, db_config, **kwargs): - """ - db_config example: + """db_config example: { - "path": "/path/to/db.duckdb", # 数据库文件路径,使用 ":memory:" 表示内存模式 - "schema": "sales", # 可选,默认 'main' - "read_only": True, # 可选,默认 False (内存模式下强制为 False) - "config": {"memory_limit": "500mb"}# 可选,DuckDB 连接配置 + "path": "/path/to/db.duckdb", # file path of duckdb, use ":memory:" for in-memory mode + "schema": "sales", # optional, 'main' by default + "read_only": True, # optional, False by default, (will set to False if in in-memory mode) + "config": {"memory_limit": "500mb"}, # optional, duckdb connection configs } """ self._config = { @@ -28,10 +27,10 @@ def __init__(self, db_config, **kwargs): 'config': db_config.get('config', {}), } - if not self._config['path'] or self._config['path'] == ':memory:': # 标准化内存模式路径 + if not self._config['path'] or self._config['path'] == ':memory:': # in-memroy mode self._config['path'] = ':memory:' - if self._config['read_only']: # 内存数据库不支持只读模式 + if self._config['read_only']: # in-memory mode cannot be read-only LOG.warning("In-memory database cannot be read-only. Setting read_only=False.") self._config['read_only'] = False @@ -50,16 +49,14 @@ def __init__(self, db_config, **kwargs): ).connect() self._initialize_schema() - - LOG.debug( - f"DuckDB connected: {self._config['path']} [schema={self._config['schema']}, read_only={self._config['read_only']}]" - ) + msg = f"DuckDB connected: {self._config['path']} [schema={self._config['schema']}, read_only={self._config['read_only']}]" + LOG.debug(msg) except Exception as e: LOG.exception(e) raise RuntimeError('Failed to connect to DuckDB') def _prepare_database(self): - """准备数据库文件和目录""" + """Prepare the database file and its parent directory.""" path = self._config['path'] path_obj = Path(path) From 58cf1103052fb79f8d3c02d1f42708bdbfafe307 Mon Sep 17 00:00:00 2001 From: Bibo Hao Date: Wed, 10 Sep 2025 17:23:50 +0000 Subject: [PATCH 2/2] update readme --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 623c10f..050c39a 100644 --- a/README.md +++ b/README.md @@ -20,14 +20,20 @@ Please generously STAR★ our project or donate to us! [![Donate-AliPay](https://img.shields.io/badge/Donate-Alipay-blue.svg)](https://raw.githubusercontent.com/wiki/haobibo/resources/img/Donate-AliPay.png) [![Donate-WeChat](https://img.shields.io/badge/Donate-WeChat-green.svg)](https://raw.githubusercontent.com/wiki/haobibo/resources/img/Donate-WeChat.png) -- For documentation, visit: [📚 Document & 中文文档](https://aloha-python.readthedocs.io/) - - For questions, try DeepWiki: [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/QPod/aloha-python) - To contribute or talk to a human: [![Open an Issue on GitHub](https://img.shields.io/github/issues/QPod/aloha-python)](https://github.com/QPod/aloha-python/issues) [![Join the Discord Chat](https://img.shields.io/badge/Discuss_on-Discord-green)](https://discord.gg/kHUzgQxgbJ) ## Getting started +Refer to[📚 Document & 中文文档](https://aloha-python.readthedocs.io/) for detailed introduction. + ```shell pip install aloha[all] ``` + +And then: +```python +from aloha.logger import LOG +from aloha.settings import SETTINGS as S +```