A lightweight tool for interacting with Quickbase's RESTful API
Project description
my-quickbase
A simple means to interact with Quickbase databases, making use of Quickbase's RESTful API.
Requirements
- pytest
- requests
- python-decouple
Installation
pip install my-quickbase
Usage
Backup All Tables
The complete_backup method will produce a folder of JSON backups for every report in every table, where the report name contains the string 'BACKUP'
For example:
To commence the backup:
import my_quickbase as mq
query = mq.AppQuery(app_id='xxxxxx',
realm='myrealm.quickbase.com',
token='QB-USER-TOKEN xxxxxxx')
query.complete_backup()
Note: The realm and token parameters can be optional if variables Q_REALM and Q_USER_TOKEN are added to the environment variables or added to a settings.ini file.
Acquire Iterable of Records for a Single Report
Returns a generator expression comprising an iterable of other generator objects, each representing an API call. The actual calls are only made when something is done with the data (e.g. converting to list, exporting to JSON).
query = mq.RecordsQuery(app_id='xxxxxx',
table_id='xxxxx'
realm='myrealm.quickbase.com',
token='QB-USER-TOKEN xxxxxxx')
# This must be called first
query.get_field_mapping()
# Returns a generator expression, which can be converted:
query.get_records(report_id='12345')
# e.g. Convert to List:
records_lst = list(query.get_records(report_id='12345'))
Insert or Update Records
Inserting or updating a record relies on the RecordQuery and its upsert_data() method.
This method requires a list of dictionaries, with each dictionary creating/updating a single record. MyQuickbase then converts this input list into the format required by Quickbase's API.
Each of these dictionaries used as an input parameter to the upsert_data() method must contain a mapping of field IDs numbers to a value. For example:
data = [
{
"5": 'fish', # Text
"11": 100, # Numeric-Currency
"3": 1420 # Record ID #
},
{
"5": 'fosh',
"11": '$540',
"3": 1421
},
]
The maximum payload size is 10mb. You may need to divide data into chunks, if upserting a particular large amount.
Formatting of data values is explained in Quickbase API docs here: https://developer.quickbase.com/fieldInfo
Example use:
query = mq.RecordsQuery(app_id='xxxxxx',
table_id='xxxxx'
realm='myrealm.quickbase.com',
token='QB-USER-TOKEN xxxxxxx')
query.get_field_mapping()
data_insert = [
{
"6": "bish",
"7": 800
},
{
"6": "bosh",
"7": 3500
}
]
response = query.upsert_data(data_insert) # Returns requests response,
# including details of which records updated/inserted/failed
To update an existing record, simply include the record ID field ID as a key to each dictionary, along with the record ID value.
e.g, if Record ID field ID is 3, and ID of record to be updated is 10:
data_update = [
{
"6": "moose",
"7": 340.
"3": 10
}
]
response = query.upsert_data(data_update)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file my-quickbase-0.2.1.tar.gz
.
File metadata
- Download URL: my-quickbase-0.2.1.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 028bed3c6eb0b05a84a31c6230be8a55ee56407d3be2c8387a861f4419e76790 |
|
MD5 | 48472364ab34ff57b83a749d98532a40 |
|
BLAKE2b-256 | 085d819e99e9dd4d28b8cf8ccda123a8235580c639636a589d42969b08ff7475 |
File details
Details for the file my_quickbase-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: my_quickbase-0.2.1-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a60ff666fd87718738ba2f5776d9f8737c7ed0838cf670dd54b2cfd13df4f332 |
|
MD5 | dd5f8ce21abb4422b20d97324a289ee5 |
|
BLAKE2b-256 | bb86bebe69d39c129123b5e1f5a87b1598153791ef49fa0f06caac1eb6d1fefc |