I've got a new QGIS 3 install from Kingchaos on osx, but have few issues. One of them is with db manager and sqlite database.

This is the error I got:

Une erreur est survenue lors de l'éxécution du code Python: 

AttributeError: 'sqlite3.Connection' object has no attribute 'enable_load_extension' 
Traceback (most recent call last):
  File "/Applications/QGIS 3.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_model.py", line 441, in rowCount
    self._refreshIndex(parent, True)
  File "/Applications/QGIS 3.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_model.py", line 490, in _refreshIndex
    if item.populate():
  File "/Applications/QGIS 3.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_model.py", line 167, in populate
    if not connection.connect():
  File "/Applications/QGIS 3.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/spatialite/plugin.py", line 80, in connect
    return self.connectToUri(uri)
  File "/Applications/QGIS 3.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/plugin.py", line 109, in connectToUri
    self.db = self.databasesFactory(self, uri)
  File "/Applications/QGIS 3.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/spatialite/plugin.py", line 66, in databasesFactory
    return SLDatabase(connection, uri)
  File "/Applications/QGIS 3.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/spatialite/plugin.py", line 109, in __init__
    Database.__init__(self, connection, uri)
  File "/Applications/QGIS 3.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/plugin.py", line 218, in __init__
    self.connector = self.connectorsFactory(uri)
  File "/Applications/QGIS 3.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/spatialite/plugin.py", line 112, in connectorsFactory
    return SpatiaLiteDBConnector(uri)
  File "/Applications/QGIS 3.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/spatialite/connector.py", line 51, in __init__
    self.connection = spatialite_connect(self._connectionInfo())
  File "/Applications/QGIS 3.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 596, in spatialite_connect
AttributeError: 'sqlite3.Connection' object has no attribute 'enable_load_extension'

Version de Python : 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] 
Version de QGIS : 3.0.0-Girona Girona, exported 

Chemin Python :
/Applications/QGIS 3.app/Contents/MacOS/../Resources/python
/Users/arthur/Library/Application Support/QGIS/QGIS3/profiles/default/python
/Users/arthur/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins
/Applications/QGIS 3.app/Contents/MacOS/../Resources/python/plugins
/Users/arthur/Library/Application Support/QGIS/QGIS3/profiles/default/python
/Users/arthur/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/mmqgis/forms

2 Answers 2


I see the same thing. I'm using a slightly newer version than you (KyngChaos build 3.0.0-3).

I can successfully drag and drop sqlite / spatialite / GPKG from the browser panel, but not add them from Db Manager. This might be a workaround in some cases.

This appears to be a build issue with the standard Python framework on Mac OS X, rather than QGIS specifically.

To quote the first source (emphasis mine)

You must install Python from scratch, enabling the loadable extension support at compile time.

It seems that this functionality needs to be compiled into the python framework on the mac as it's not enabled by default.

I found the same error attempting to do this in standalone python; I could get it to work with the sqlite3 from the homebrew python setup, but not the official python framework.

This is not an easy end-user change as it involves compiling a custom version of Python. The KyngChaos install pages specifically state that you should be using the standard Python framework, rather than (say) one from MacPorts or Homebrew.

  • Tank you for this usefull information. The drag&drop tip could help some, but I need to use the db manager to get access to SQL querries. I will search in your links how to enable the "loadable extension support". But if I get you it needs to compile another python version which seems far too complicated for me
    – Arthur
    Mar 26, 2018 at 7:36
  • i see Issue ticket #18430, have updated that too.
    – Steven Kay
    Mar 28, 2018 at 9:41
  • I took some time to try to install python3 with brew. but this did not change my issue. I think the post you pointed out by Riccardo Forina is quite old and maybe only works for Python2 and not Python3? I think there is some issues with the folder it get installed.
    – Arthur
    Apr 11, 2018 at 13:39
  • Looks like Qgis won't use the good python3.6 version. To install QGIS I had to install the standard Python. Then with your help I installed it with the terminal. But even trying to add some symlink I didn't get it working. This is a huge issue as I can't make any sql querry
    – Arthur
    Apr 12, 2018 at 9:50
  • Hello, I tried to follow the posted links but yet could not find a solution. The solution offered in QGIS site download page does not work (official Python release). Should I install brew's Python? Should I compile my own version? Nov 23, 2018 at 16:27

I am getting the same issue and way too scared to start fiddling with the system Python.

My workaround at the moment is to use virtual layers and do the query from there. I found the virtual layer can really slow down and occasionally freeze QGIS so not ideal either...

Virtual Layer Example

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.