I've narrowed down my problem space a bit. Consider this simple code:
from sqlalchemy import (Integer, String, Column, MetaData, create_engine)
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
METADATA = MetaData()
BASE = declarative_base(metadata=METADATA)
SESSION = sessionmaker()
class User(BASE):
__tablename__ = "user"
first_name = Column(String(32))
last_name = Column(String(32))
id = Column(Integer, primary_key=True)
print(type(User))
print(type(METADATA.tables['user']))
When run, I get this output:
<class 'sqlalchemy.ext.declarative.api.DeclarativeMeta'>
<class 'sqlalchemy.sql.schema.Table'>
The User class is suitable to use as the first arg to
session.bulk_insert_mapping(), but the object plucked from the METADATA
tables dict is not. Will I have to always carry around my own references to
the various subclasses of BASE which I defined to describe my schema? If I
have metadata and session objects, is there a way to get back that usable
(or a usable) class?
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.