Skip to content

Instantly share code, notes, and snippets.

@isaacharrisholt
Created October 8, 2022 12:55
Show Gist options
  • Select an option

  • Save isaacharrisholt/3defeb38632ac05e59099a84649cda4c to your computer and use it in GitHub Desktop.

Select an option

Save isaacharrisholt/3defeb38632ac05e59099a84649cda4c to your computer and use it in GitHub Desktop.
The tables for the example
from sqlalchemy import (
Boolean,
Column,
ForeignKey,
Integer,
String,
)
from sqlalchemy.orm import declarative_base
Base = declarative_base()
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String(50))
class Order(Base):
__tablename__ = 'orders'
id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey('users.id'))
description = Column(String(50))
payment_status = Column(Boolean, index=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment