|
|
import os |
|
|
from airs.base import Base |
|
|
from dotenv import load_dotenv |
|
|
|
|
|
|
|
|
load_dotenv() |
|
|
|
|
|
def test_read_tasks(): |
|
|
print("正在初始化 Base 类...") |
|
|
base_instance = Base() |
|
|
print("Base 类初始化完成。") |
|
|
|
|
|
try: |
|
|
print("正在尝试从 'tasks' 表读取数据...") |
|
|
|
|
|
response = base_instance.supabase.table('tasks').select('*').execute() |
|
|
|
|
|
if response.data: |
|
|
print("成功读取数据:") |
|
|
for task in response.data: |
|
|
print(task) |
|
|
return {"success": True, "tasks": response.data} |
|
|
else: |
|
|
print("未读取到数据或发生未知错误。") |
|
|
return {"success": False, "error": response.error.message if response.error else "No data or unknown error"} |
|
|
except Exception as e: |
|
|
print(f"读取数据时发生错误: {e}") |
|
|
return {"success": False, "error": str(e)} |
|
|
|
|
|
if __name__ == "__main__": |
|
|
result = test_read_tasks() |
|
|
print("\n测试结果:") |
|
|
print(result) |
|
|
|