Giter Site home page Giter Site logo

vikadata / vika.py Goto Github PK

View Code? Open in Web Editor NEW
73.0 73.0 17.0 281 KB

Vika is a API-based SaaS database platform for users and developers,here's Python SDK for integration. 维格表(vika.cn)官方 Python SDK, 让你轻松集成维格表的 可视化API数据库能力。

License: MIT License

Python 99.73% Makefile 0.27%
vika

vika.py's People

Contributors

borye avatar chamberschan avatar dage233 avatar dependabot[bot] avatar elfgzp avatar github-actions[bot] avatar gltjk avatar itou-ng avatar kwp-lab avatar mayneyao avatar mr-kelly avatar xukecheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vika.py's Issues

API Server Error: 504

运行一段时间后会报错:vika.exceptions.ServerError: API Server Error: 504,请问是触发了什么限制吗?

vika无法安装

为什么vika模块无法安装?什么报错信息都没有,只提示了无法安装

BUG : datasheet.records.bulk_create failed

for a vika datasheet like below

image

我想执行批量添加数据。

    records = datasheet.records.bulk_create(
        [
            {"title": "new record from Python SDK"},
            {"title": "new record from Python SDK2"},
        ]
    )

report error

  File "d:\quant\cmp\cmp\utils\vika_table.py", line 92, in <module>
    save_dataframe_to_vika()
  File "d:\quant\cmp\cmp\utils\vika_table.py", line 81, in save_dataframe_to_vika
    record = datasheet.records.create({"title": "new record from Python SDK"})
  File "C:\Python39\lib\site-packages\vika\datasheet\record_manager.py", line 49, in create    
    resp = self._dst.create_records(data)
  File "C:\Python39\lib\site-packages\vika\datasheet\datasheet.py", line 190, in create_records
    return handle_response(resp, PostRecordResponse)
  File "C:\Python39\lib\site-packages\vika\utils.py", line 81, in handle_response
    raise Exception(r['message'])
Exception: The format of the fields parameter value is wrong

please support filter with bool

image

records = datasheet.records.filter(selected=True)

Am I calling with the wrong way ?

Not support in source code ?

def query_parse(field_key_map: FieldKeyMap, **kwargs):
    """
    将查询条件转化为 filterByFormula
    records.filter(title="hello", subtitle="world") => '{title}="hello" AND {subtitle}="world"'
    1. 通过 filter 和 get 参数查询到的只能转化为 and 条件。
    """
    query_str = ""
    for k, v in kwargs.items():
        if query_str:
            query_str += " AND "
        # 处理空值
        if v is None:
            v = 'BLANK()'
        # 处理字符串
        if isinstance(v, str):
            v = f'"{v}"'
        # 处理数组类型的值,多选,成员?
        if isinstance(v, list):
            v = f'"{", ".join(v)}"'
        query_str += f'{{{trans_key(field_key_map, k)}}}={v}'
    return query_str

Exception: Unauthorized

配置完API Token和datasheetid后运行报错Exception: Unauthorized如何解决 python3.10.4

API无法正确更新附件数组内的多个值

Python SDK
使用field ID更新的代码如下:
img_v2_b3e68128-7cc6-4eac-9e1a-9a45606a239g
在查询获得record的时候,record里的数据都是fieldname表示的,而不是fieldid,我用fieldid去判断对应的字段是否为空,是无法正确判断的,第一个print的结果如下,红框是要更新的字段
32664d31-bd6b-4e5a-a506-5a3c04d8292d
第二个print结果如下
be6038d2-e5e9-40db-b02b-78b7c9a37f30
显示新增了一个fieldID的字段,而不是更新'白底图'的数组
然后我再对这条记录查询一次,会发现'白底图'的内容被更新成了'fldkt4vmm79Uv'的内容,原来白底图的内容丢失。
16cfb6e4-9c5b-48e6-9137-07d4bd785e69

然后我就尝试不用fieldid,直接用fieldname,代码修改成
5e55588d-da67-47b5-a74d-b05890c1d513
重新测试。第一次print打印出原始的记录内容
a4dd17b5-b3a7-47e0-87c6-42ac6ef7d696

第二次print打印出更新后的记录内容,能看到数组里有两条记录
bd09a5e2-3f9f-44a3-8cac-5f4d58a551d1
但是重新根据skuid查询后发现,实际记录数组里还是只有一个
b0509bd6-ddfe-447c-8367-2e8e8d627904

所以Python的sdk下到底应该怎么更新一个数组字段的值?

feat: sdk 升级 技术 文案 编写

🚀🚀🚀 发布基于 DataBus v3 版本 fusion api 的 sdk

我们采用渐进式升级的策略, 当前阶段只开放一个查询行 get records 的接口。

关于 curl

curl --location 'https://vika.cn/fusion/v3/datasheets/{dstId}/records?fieldKey=name' \
--header 'Authorization: Bearer {token}'

关于 javascript

安装 beta 版本的依赖

npm i @vikadata/[email protected]

// apitable 
npm i [email protected]

只需要在 sdk 调用 api 时增加 isV3 的支持即可启用 v3 版本的 sdk

    const token = 'xxxx';
    const datasheetId = 'dstXXXX';
    const apitable = new Vika({
        token
    });

    const datasheet = apitable.datasheet(datasheetId);

    // 添加 isV3 参数调用 v3 版本的 fusion api
    const  records = await datasheet.records.query({ isV3: true });

关于python

安装 beta 版本的依赖

pip install apitable==2.0.0b4

只需要在 sdk 调用 api 时增加 isV3 的支持即可启用 v3 版本的 sdk

    token = 'xxxx';
    datasheetId = 'dstXXXX';
    apitable = Apitable(token)

    dst = apitable.datasheet(datasheetId)

    // 添加 isV3 参数调用 v3 版本的 fusion api
    parameter = { "isV3": True }
    records = self.dst.records.all(**parameter)

关于 java

安装 beta 版本的依赖

<dependency>
    <groupId>cn.vika</groupId>
    <artifactId>vika-client</artifactId>
    <version>1.0.4</version>
</dependency>

只需要在 sdk 调用 api 时增加 isV3 的支持即可启用 v3 版本的 sdk

    String token = 'xxxx';
    String datasheetId = 'dstXXXX';
    final ApitableApiClient apitableApiClient = new ApitableApiClient(new ApiCredential(token));

    // 添加 isV3 参数调用 v3 版本的 fusion api
    Pager<Record> pager = apitableApiClient.getRecordApi().getRecords(datasheetId, true);

请求中指定pageNum,却返回所有记录

代码 vika.py 中,与文档不符:当调用 all 时,显式地传入参数,则利用服务端计算返回部分数据集。

    if resp.success:
        records += resp.data.records
        if current_total < resp.data.total:
            kwargs.update({"pageNum": page_num + 1})
            records += self.fetch_datasheet(dst_id, **kwargs)

更新pydantic版本依赖

建议更新pydantic依赖,而不是限制版本。
当前版本较老,与其他项目存在冲突:

confection 0.1.4 requires pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4, but you have pydantic 1.7 which is incompatible.
spacy 3.7.2 requires pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4, but you have pydantic 1.7 which is incompatible.
thinc 8.2.1 requires pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4, but you have pydantic 1.7 which is incompatible.
weasel 0.3.4 requires pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4, but you have pydantic 1.7 which is incompatible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.