# Airtable Caching
![PyPI](https://img.shields.io/pypi/v/airtable_caching)
![PyPI - Downloads](https://img.shields.io/pypi/dm/airtable_caching)
![PyPI - License](https://img.shields.io/pypi/l/airtable_caching)
Utility for caching api responses from the airtable-python-wrapper and provides an ORM style interface for querying cached records.
>Dummy api key and base keys provided below for testing. Please do not modify anything using this key, or I will have to take this option away.
## Installation
```bash
pip install airtable-caching
```
## Step 1 - Import classes
```python
from airtable_caching import Base, Table
```
## Step 2 - cache a table
```python
base = Base(base_id="appjMwyFviPaM9I0L", api_key="keyqhxncgPbSySJQN")
base.cache_table("Table 1")
```
## Step 3 - Access cached data
```python
table = Table(base_id="appjMwyFviPaM9I0L", table_name="Table 1")
# get single record by it's airtable record ID
table.get('rec4trz5QrB6aWJBw')
# get all records in the table
table.query().all()
# get all records and resolve linked fields
table.query(resolve_fields={"Table 2": "Link to Table 2"}).all()
# get the first record in table
table.query().first()
# get the last record in table
table.query().last()
# filtering records in the query
table.query().filter_by({"Name": "Data entry 1 from Table 1 from Base 1"}).all()
# ordering records in the query
table.query().order_by("Number").all()
# ordering records in the query (descending)
table.query().order_by("Number", desc=True).all()
```
## Defining a custom cache folder location
By default this stores all cached data as .json files in airtable_caching/json. You can optionally pass a custom folder location to the Base and Table classes.
```python
import os
custom_json_folder = os.path.join(os.path.dirname(__file__), "custom_json")
base = Base(
base_id="appjMwyFviPaM9I0L",
api_key="keyqhxncgPbSySJQN",
json_folder=custom_json_folder,
)
table = Table(
base_id="appjMwyFviPaM9I0L",
table_name="Table 1",
json_folder=self.custom_json_folder,
)
```
## Changelog
### 0.0.4
#### Updated
- README and docstrings
### 0.0.3
#### Changed
- (BREAKING) Base and Table classes no longer use base name, now they use base id (see docs)
- added option for supplying custom cache location
#### Added
- Documentation
- Tests
### 0.0.1 - 0.0.2
- Initial release
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共10个文件
txt:4个
pkg-info:2个
py:2个
资源分类:Python库 所属语言:Python 资源全名:airtable-caching-0.0.4.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
airtable-caching-0.0.4.tar.gz (10个子文件)
airtable-caching-0.0.4
PKG-INFO 3KB
airtable_caching.egg-info
PKG-INFO 3KB
requires.txt 24B
SOURCES.txt 256B
top_level.txt 17B
dependency_links.txt 1B
airtable_caching
__init__.py 9KB
setup.cfg 79B
setup.py 748B
README.md 2KB
共 10 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功