Is there a simple one-line way using peewee
in Python of either inserting a record if the primary key does not already exist, or updating the record if it does already exist.
Currently i am using the code:
try:
sql_database.create(record_key = record_key, record_data_2 = record_data_2)
except IntegrityError: ## Occurs if primary_key already exists
sql_database.update(record_key = record_key, record_data_2 = record_data_2)
I couldn't see a "create or update" command, but maybe i am missing something.