Python 如何在新类中继承所有sqlalchemy函数?
我尝试了一些先天性痤疮的组合,但都不起作用。这就是我最后得到的Python 如何在新类中继承所有sqlalchemy函数?,python,inheritance,sqlalchemy,Python,Inheritance,Sqlalchemy,我尝试了一些先天性痤疮的组合,但都不起作用。这就是我最后得到的 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:therea
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:thereader@sentiodb.cloudapp.net/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)
这给
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)
我肯定错过了一些新手的观点。有什么方法可以做到这一点吗?
sqlalchemy
是一个模块,而不是一个类。您不应该尝试从它继承。那么是否有其他方法可以从我的自定义类定义中调用它的所有函数?不,Python中不是这样使用函数的。导入它们并在它们所在的位置使用它们。