Inspiration
- When originally working with the QuickBase API through python, we found the most difficult part being always referring to fields by some numerical ID in the code. I found myself writing many many variables just to alias these IDs, to make the code more readable.
- Similarly, it was sometimes difficult to build queries just using a string in the QuickBase query language
- QuickBase recently rolled out the new RESTful JSON API, we wanted to specifically target these new endpoints
- More readable code is easier to maintain, and code that is easier to maintain makes our systems more responsive and robust
What it does
- This open source Python package serves as a utility for developers to interface with QuickBase using a higher-level Python wrapper.
- It includes a utility which goes through the QuickBase API (specifically the get tables for app, and the get fields for table endpoints), to generate a Python class that can then be used to interact with records in QuickBase tables as if they are python objects. It generates classes that can be used like below:
client = GitHubIssue.client(user_tok=os.environ['QB_USER_TOKEN'])
new_issue = GitHubIssue(
title='Something broke', # you get friendly-kwargs for fields without worrying about ID's
description='Please fix!',
date_opened=date.today() # things like Python date objects will be serialized
)
response = client.add_record(new_issue)
print(response.json()) # all methods (except for query) return the requests Response object
- It also includes utilities for helping build query strings to run QuickBase queries from Python code.
from quickbase_client.query import on_or_before_, eq_, and_
schema = GitHubIssue.schema
q = and_(
eq_(schema.date_opened, schema.date_created),
on_or_before_(schema.date_closed, date(2020, 11, 16))
)
print(q.where) # ({'9'.EX.'_FID_1'}AND{'10'.OBF.'11-16-2020'})
recs = client.query(q) # recs will be GitHubIssue objects unless passing raw=True
print([str(r) for r in recs]) # ['<GitHubIssue title="Made And Closed Today" id="10000">']
How I built it
- Using python and the QuickBase API, with a test QuickBase app here
What's next for High Level Python and QuickBase Interfacing
- We decided to make this project open source to build the QuickBase developer community and collectively enhance the package
- We will continue to enhance for our own use, and add more features
- Some features include handling composite fields like Addresses, other QueryBuilding classes, and more.
Log in or sign up for Devpost to join the conversation.