Open
Description
First Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the SQLModel documentation, with the integrated search.
- I already searched in Google "How to X in SQLModel" and didn't find any information.
- I already read and followed all the tutorial in the docs and didn't find an answer.
- I already checked if it is not related to SQLModel but to Pydantic.
- I already checked if it is not related to SQLModel but to SQLAlchemy.
Commit to Help
- I commit to help with one of those options 👆
Example Code
class MetricBase(SQLModel):
id: Optional[int] = Field(default=None, primary_key=True)
fact_name: str
dimensions: Optional[List] = Field(default=[])
measures: Optional[List] = Field(default=[])
params: Optional[Dict]
Description
It would be nice to show a few examples about how to model arrays and json SQL columns.
In general what principles should I follow to convert from a SQLAlchemy Table definition?
Operating System
Linux
Operating System Details
Ubuntu 21.0
SQLModel Version
0.0.8
Python Version
3.8.10
Additional Context
For example I am trying to convert this existing table:
from sqlalchemy import Column, Integer, String, DateTime, BigInteger, SmallInteger,LargeBinary, ForeignKey, Table, Float,Boolean
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.dialects.postgresql import JSONB,JSON, ARRAY
class Metrics(Base):
__tablename__ = 'metrics'
__table_args__ = {'extend_existing':True}
# billing item id
id = Column(BigInteger, autoincrement=True, primary_key=True)
# the fact name
fact_name = Column(String,nullable=False)
dimensions = Column(ARRAY(String))
measures = Column(ARRAY(String))
sql_query = Column(String)
rest_query = Column(String)
params_query = Column(JSON)
chart_types = Column(JSON)
chart_title = Column(String)