File size: 1,067 Bytes
4b2a02f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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' 表读取数据...")
        # 直接使用 Supabase 客户端查询
        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)