Even though I put the file in a directory define in %PATH% or try with/without full path, with/without file extension, with libspatialite-4.dll or using excute with all combination mentionned before... dbapi_conn.execute("SELECT load_extension('mod_spatialite.dll')")
Le mercredi 10 juillet 2019 08:53:21 UTC-4, Michael Lane a écrit : > > Try to find a way to import the dll but it always fails on the > load_extension > > def load_spatialite(dbapi_conn, connection_record): > dbapi_conn.enable_load_extension(True) > dbapi_conn.load_extension('C:\\Scripts\\*mod_spatialite*.dll') > > > Le mardi 9 juillet 2019 17:01:33 UTC-4, Michael Lane a écrit : >> >> I would like to use spatialite <https://pypi.org/project/spatialite/> in >> my project but I don't find the right way to do that. Does anybody have >> already done that and can give me an example? >> >> my environment: >> >> Windows 10: >> Python version: 3.6.8 >> Local database: sqlite (for spatialite) >> Remote database: postgresql >> >> I find a lot of exemples where spatialite is set in the module parameter >> for the engine <https://docs.sqlalchemy.org/en/13/core/engines.html> in >> create_engine using lib like libsqlite3, mod_spatialite, pysqlite3 in my >> case I use spatialiteinstall with pip (package define in setup.py) >> >> My problem is then I don't have the control of create_engine, in the >> engine comming from settings in ini so I think that I have to pass the >> setting by the ini file but I did'nt get it. I didn't find any good example >> of code using same combination environment as mine (windows, pyramid, >> spatialite). >> >> >> There are the settings of ini file: >> >> >> pyramid.reload_templates = true >> pyramid.reload_assets = true >> pyramid.debug_authorization = true >> pyramid.debug_notfound = false >> pyramid.debug_routematch = true >> pyramid.default_locale_name = en >> pyramid.includes = >> pyramid_debugtoolbar >> pyramid_tm >> >> sqlalchemy.url = sqlite:///%(here)s/risc.sqlite >> >> >> Code where the engine is create: >> >> >> from sqlalchemy import engine_from_configfrom sqlalchemy.orm import >> sessionmakerfrom sqlalchemy.orm import configure_mappersimport >> zope.sqlalchemy >> >> # run configure_mappers after defining all of the models to ensure# all >> relationships can be setup >> configure_mappers() >> >> def get_engine(settings, prefix='sqlalchemy.'): >> return engine_from_config(settings, prefix) >> >> def get_session_factory(engine): >> factory = sessionmaker() >> factory.configure(bind=engine) >> return factory >> >> def get_tm_session(session_factory, transaction_manager): >> dbsession = session_factory() >> zope.sqlalchemy.register(dbsession, >> transaction_manager=transaction_manager) >> return dbsession >> >> def includeme(config): >> settings = config.get_settings() >> settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager' >> >> # use pyramid_tm to hook the transaction lifecycle to the request >> config.include('pyramid_tm') >> >> # use pyramid_retry to retry a request when transient exceptions occur >> config.include('pyramid_retry') >> >> session_factory = get_session_factory(get_engine(settings)) >> config.registry['dbsession_factory'] = session_factory >> >> # make request.dbsession available for use in Pyramid >> config.add_request_method( >> # r.tm is the transaction manager used by pyramid_tm >> lambda r: get_tm_session(session_factory, r.tm), >> 'dbsession', >> reify=True) >> >> >> And the settings module of setup.py >> >> >> requires = [ >> 'bcrypt', >> 'docutils', >> 'plaster_pastedeploy', >> 'pyramid', >> 'pyramid_debugtoolbar', >> 'pyramid_retry', >> 'pyramid_tm', >> 'sqlalchemy', >> 'transaction', >> 'zope.sqlalchemy', >> 'waitress', >> 'sphinx', >> 'flake8', >> 'pyLint', >> 'pg8000', >> 'geoalchemy2', >> 'spatialite'] >> >> >> I'm pretty sure than I miss a little something, but I'm not able to find >> it my way. I little hint will be appreciated on this one. >> >> >> Thanks >> > -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To post to this group, send email to pylons-discuss@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/3b03aac9-9b76-4e1f-b059-ae781a5203cc%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.