I have couple of tables in my bigquery dataset. I would like to not write by hand model definitions, but to use reflection as described on page: https://docs.sqlalchemy.org/en/14/orm/extensions/automap.html . I have prepared some example:
from sqlalchemy import create_engine, Table, MetaData, Column, Integer, String
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
engine = create_engine('bigquery://<my-gcloud-project-id>')
metadata = MetaData()
metadata.reflect(engine, only=['websites.<my-table-to-reflect>',])
Base = automap_base(metadata=metadata)
Base.prepare()
print(Base.classes.items())
print(list(Base.classes))
But I'm getting empty list. Am I doing something wrong, or automap is not supported with bigquery? My deps: sqlalchemy-bigquery==1.2.2; SQLAlchemy==1.4.27; google-cloud-bigquery==2.27.0;
Aucun commentaire:
Enregistrer un commentaire