Invalid SQLAlchemy Model
See original GitHub issueHey guys I hope someone can help me on this, i’m really stuck…
database automaping:
engine = create_engine(" blablabla", convert_unicode=True)
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))
Base = automap_base()
Base.prepare(engine, reflect=True, generate_relationship=_gen_relationship, name_for_scalar_relationship = name_for_scalar_relationship, classname_for_table=camelize_classname, name_for_collection_relationship=pluralize_collection)
Buyer = Base.classes.Buyer
Base.query = db_session.query_property()
schema :
import graphene
import json
from graphene import relay
from graphene_sqlalchemy import SQLAlchemyConnectionField, SQLAlchemyObjectType
from database import Buyer as BuyerModel
class Buyer(SQLAlchemyObjectType):
class Meta:
model = BuyerModel
interfaces = (relay.Node, )
class Query(graphene.ObjectType):
node = relay.Node.Field()
all_buyers = SQLAlchemyConnectionField(Buyer)
schema = graphene.Schema(query=Query)
Produces the error :
AssertionError: You need to pass a valid SQLAlchemy Model in Buyer.Meta, received "<class 'sqlalchemy.ext.automap.Buyer'>".
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
SqlAlchemy 'field' is an invalid keyword argument for <Model>
1. This error is raised if a keyword argument passed to the default constructor does not match an attribute on the model class....
Read more >Error Messages - SQLAlchemy 1.4 Documentation
InternalError¶. Exception raised when the database encounters an internal error, e.g. the cursor is not valid anymore, the transaction is out of sync,...
Read more >ORM Exceptions — SQLAlchemy 1.4 Documentation
SQLAlchemy ORM exceptions. ... An attempt to access unloaded attributes on a mapped instance that is detached. ... A invalid condition was detected...
Read more >Connection Pooling - SQLAlchemy 1.4 Documentation
When using a Engine , the Connection.invalidate() method is the usual entrypoint to explicit invalidation. Other conditions by which a DBAPI ...
Read more >Core Exceptions - SQLAlchemy 1.4 Documentation
Raised when an invalid or conflicting function argument is supplied. This error generally corresponds to construction time state errors. Class signature.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

There’s probably something wrong with your SQLAlchemy models, and nothing to do with the graphene schema. I recently opened #121 explaining a bug that graphene-sqlalchemy does not show you the actual error. Your can try to put a breakpoint in
is_mapped_classto see the exception SQLAlchemy is throwing.@aguaguilar can you clarify?