Add unique identifiers to your tables

Generate UUIDs for automatic row identification.

Core Operations · Notebook · Updated

Colab runs it in your browser. If it calls a model provider, it asks for that provider's API key in a cell.

How it works

You use uuid7() to generate UUIDs for each row. Define it in the schema with {'column_name': uuid7()} syntax, or add it to existing tables with add_computed_column().

What it covers

  • Create tables with auto-generated UUID primary keys
  • Add UUID columns to existing tables
  • Generate UUIDs with uuid7()

What it uses

Install
terminal
pip install pixeltable
Pixeltable calls
uuid.uuid7()pxt.create_table()insert()add_computed_column()

A look at the code

workflow-uuid-identity.ipynb
# Create table with auto-generated UUID primary key
products = pxt.create_table(
'uuid_demo/products',
{
'id': uuid7(), # Auto-generates UUID for each row
'name': pxt.String,
'price': pxt.Float,
},
primary_key=['id'],
)

One cell of the notebook, copied as it is. Open it in Colab for the rest.

Browse all 103