title: How to autogenerate UUID for Postgres in Python?
body: <p>I'm trying to create objects in Postgres db.</p>
  
  <p>I'm using this approach <a href="https://websauna.org/docs/narrative/modelling/models.html#uuid-primary-keys" rel="noreferrer">https://websauna.org/docs/narrative/modelling/models.html#uuid-primary-keys</a></p>
  
  <pre><code>class Role(Base):
      __tablename__ = 'role'
  
      # Pass `binary=False` to fallback to CHAR instead of BINARY
      id = sa.Column(UUIDType(binary=False), primary_key=True)
  </code></pre>
  
  <p>But when I create object </p>
  
  <pre><code>user_role = Role(name='User')
  db.session.add(user_role)
  db.session.commit()
  </code></pre>
  
  <p>I have the following error:</p>
  
  <pre><code>sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) null value in column "id" violates not-null constraint
  </code></pre>
  
  <p>Looks like I didn't provide any ID. So, how I can make the database auto-generate it or generate on my own?</p>