question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid SQLAlchemy Model

See original GitHub issue

Hey 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:closed
  • Created 5 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
Fedaltocommented, Mar 27, 2018

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_class to see the exception SQLAlchemy is throwing.

3reactions
flipbit03commented, Sep 16, 2020

@aguaguilar can you clarify?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found