I’m generating and then needing to store a uuid4 in a SQLite table (it will not serve as PK). I’d like to ensure that it’s stored as efficiently as possible because there are close to a million records and this can in future grow significantly.
I defined the column
item_uuid as a blob in SQLite and will be generating and storing the uuid via a Python script.
My code snippet (which works) is as follows:
# generate a uuid v4 value and run an update query to store it uuidval = str(uuid.uuid4()) dbcursor.execute('''UPDATE table SET item_uuid = (?) WHERE rowid = (?);''', (uuidval, record))
I was hoping I could store it without converting to string, but SQLite rejects inserting
uuidval if not converted to a string first.
Am I missing a trick or have I gone about this correctly?