Open jclark-dot-org opened 3 months ago
This appears to be a documentation issue.,
Took a look in the code; looks like pk
is required for upsert, despite the docs saying,
Note that the pk and column_order parameters here are optional if you are certain that the table has already been created. You should pass them if the table may not exist at the time the first upsert is performed.
So I modified my method to pass the pk as a tuple and it's working fine.
def summarize(db, table, source, object_name, category='All', criteria=None):
db['summary'].upsert({
'source': source,
'object': object_name,
'category': category,
'count': table.count_where(criteria)
}, pk=("source", "object", "category"))
Given this table:
I'd like to have a simple helper to run rollups like so:
To use like so:
But I'm getting an error that
upsert
requires apk
:Per the upsert docs, the
pk
param toupsert()
is only used when creating the target table, which I am not, so I'm assuming the error means it doesn't like my pk. Is that because it's a compound key? Or am I doing something else wrong?