erogol
erogol

Reputation: 13614

How can I inherit all sqlalchemy functions inside a new class?

I tried some of inharitacne combinations but do not work any of all. This is what I got finally

import sqlalchemy
class SentioDB(sqlalchemy):

    def __init__(self):
        #Create and engine and get the metadata
        Base = declarative_base()
        self.engine = create_engine('mysql://sentio_reader:[email protected]/sentio')
        self.engine.echo = True
        self.metadata = MetaData(bind=self.engine)
        self.metadata.reflect(bind=self.engine)
        self.create_all_tables()
        self.session = create_session(bind=self.engine) 

This gives ;

TypeError: Error when calling the metaclass bases
    module.__init__() takes at most 2 arguments (3 given)

I am missing some novice point for sure. IS there any way to do that ?

Upvotes: 0

Views: 65

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599788

sqlalchemy is a module, not a class. You shouldn't try and inherit from it.

Upvotes: 1

Related Questions