sqlite3.Connection对象在MAC上没有属性“enable\u load_extension”

2024-09-23 22:24:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我实现了一个Python应用程序,它在Windows上运行。 我想在macossierra运行这个应用程序。在

我的应用程序正在使用SQLAlchemy库。在

我有一个类代表我的数据库连接:

class DB():
'''
Represents the primary blackboard of the system.
'''

def __init__(self):
    pass

def setUp(self):
    # read config
    configInst = getConfig()
    self._date = getConfig().eval(self.__class__.__name__, "start_date")
    self.Session = sessionmaker()
    self.Session.configure(bind=self.engine)

    self.session = self.Session()

    @event.listens_for(self.engine, "connect")
    def connect(dbapi_connection, connection_rec):
            dbapi_connection.enable_load_extension(True)
    if(getConfig().eval("OperatingSystem","windows")):
                dbapi_connection.execute('SELECT load_extension("%s%s")'%(configInst.get("DB","DB_path_to_extension"),'.dll'))
    if(getConfig().eval("OperatingSystem","mac")):
        dbapi_connection.execute('SELECT load_extension("%s%s")'%(configInst.get("DB","DB_path_to_extension"),'.dylib'))

            **dbapi_connection.enable_load_extension(False)**
    if getConfig().eval(self.__class__.__name__,"dropall_on_setup"):
        Base.metadata.drop_all(self.engine)

    Base.metadata.create_all(self.engine)
    pass

当应用程序运行时,我收到下一个错误:

^{pr2}$

我安装了Anaconda for Mac OS,但是在一行中**应用程序无法访问sqlite3.py文件。在

我不能把它联系起来。在

有人吗?在


Tags: self应用程序dbifsessiondefevalextension