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)
Metadata
Release files for my-quickbase 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| my-quickbase-0.2.1.tar.gz | 7.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| my_quickbase-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.9 kB
Release files / my-quickbase-0.2.1.tar.gz
| Download URL | my-quickbase-0.2.1.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
028bed3c6eb0b05a84a31c6230be8a55ee56407d3be2c8387a861f4419e76790
|
|
BLAKE2b-256 checksum How to use checksums |
085d819e99e9dd4d28b8cf8ccda123a8235580c639636a589d42969b08ff7475
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / my_quickbase-0.2.1-py3-none-any.whl
| Download URL | my_quickbase-0.2.1-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a60ff666fd87718738ba2f5776d9f8737c7ed0838cf670dd54b2cfd13df4f332
|
|
BLAKE2b-256 checksum How to use checksums |
bb86bebe69d39c129123b5e1f5a87b1598153791ef49fa0f06caac1eb6d1fefc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|