Skip to content

Instantly share code, notes, and snippets.

@chespinoza
Last active May 6, 2020 16:09
Show Gist options
  • Save chespinoza/dd90ddeac9cafb3c35795bf529d42d1f to your computer and use it in GitHub Desktop.
Save chespinoza/dd90ddeac9cafb3c35795bf529d42d1f to your computer and use it in GitHub Desktop.
from sqlalchemy import Column, Index, Text
from sqlalchemy.dialects.postgresql import TIMESTAMP
from sqlalchemy.dialects.postgresql.json import JSONB
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Products(Base):
__tablename__ = "products"
asin = Column(Text, primary_key=True)
title = Column(Text)
parent_asin = Column(Text)
marketplace = Column(Text)
images = Column(ARRAY(Text))
is_complete = Column(Boolean)
inserted_at = Column(TIMESTAMP(timezone=True), server_default=func.transaction_timestamp())
updated_at = Column(TIMESTAMP(timezone=True))
data = Column(JSONB)
__table__args__ = Index(
"idx_products_title", title, postgresql_using="gin", postgresql_ops={"title": "gin_trgm_ops"}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment