Bug 1066938 - Python sqlite3 module does not allow the loading of extensions (should be enabled)
Summary: Python sqlite3 module does not allow the loading of extensions (should be ena...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python3
Version: 20
Hardware: All
OS: Unspecified
unspecified
medium
Target Milestone: ---
Assignee: Bohuslav "Slavek" Kabrda
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 1066708
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-02-19 10:59 UTC by Bohuslav "Slavek" Kabrda
Modified: 2014-02-24 12:27 UTC (History)
9 users (show)

Fixed In Version: python3-3.3.2-10.fc20
Doc Type: Bug Fix
Doc Text:
Clone Of: 1066708
Environment:
Last Closed: 2014-02-24 12:27:40 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Update to original test script (#1066708), to more throughly test the fix. (2.47 KB, application/x-shellscript)
2014-02-23 19:01 UTC, John C Peterson
no flags Details

Description Bohuslav "Slavek" Kabrda 2014-02-19 10:59:25 UTC
+++ This bug was initially created as a clone of Bug #1066708 +++

Description of problem: The Python sqlite3 module does not allow the loading of SQLite extension libraries. 


Version-Release number of selected component (if applicable): python-2.7.5 (and also python3-3.3.2), and all previous releases of this


How reproducible: 100% reproducible


Steps to Reproduce: See the attached Bourne shell script; test_script.sh


Actual results: AttributeError: 'sqlite3.Connection' object has no attribute 'enable_load_extension'


Expected results: The loading of extensions is a core feature of SQLite, and should be enabled, (e.g. for using things like libspatialite)


Additional info: This problem has been reported on Bugzilla before, but probably was not routed to the correct person, see;

https://bugzilla.redhat.com/show_bug.cgi?id=814905

The upstream documentation from python.org for the sqlite3 module states that the loading of extensions is disabled by default in the source tarball. See the footnote[1] at the very end of the page for more detail;

http://docs.python.org/2/library/sqlite3.html

There should not be any issues with allowing extensions on Linux. Note that  loading of extensions is enabled in the stand alone sqlite3 application (using the ".load" command). This is a separate package sqlite-3.7.11, which builds a separate SQLite library.

The fix for this is straight forward. When building the Python RPM, the line in the setup.py script that sets SQLITE_OMIT_LOAD_EXTENSION should be commented out. The following patch does the trick;

--- Python-2.7.5/setup.py.orig  2013-05-11 20:32:54.000000000 -0700
+++ Python-2.7.5/setup.py       2014-02-18 14:16:07.999004901 -0800
@@ -1168,7 +1168,7 @@ class PyBuildExt(build_ext):
                 sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"'))
 
             # Comment this out if you want the sqlite3 module to be able to load extensions.
-            sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))
+            #sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))
 
             if host_platform == 'darwin':
                 # In every directory on the search path search for a dynamic

--- Additional comment from John C Peterson on 2014-02-18 18:20:55 EST ---



--- Additional comment from Bohuslav "Slavek" Kabrda on 2014-02-19 05:57:48 EST ---

Seems reasonable and it's an easyfix, will do. AFAICS there is a configuration option for this in Python 3, so I'll enable it there too - not with patch, but using that option.
Thanks for the report.

Comment 1 Fedora Update System 2014-02-19 15:32:13 UTC
python3-3.3.2-10.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/python3-3.3.2-10.fc20

Comment 2 John C Peterson 2014-02-19 18:45:37 UTC
Hi Bohuslav,

Thanks for attending to this so promptly!

John

Comment 3 Fedora Update System 2014-02-22 00:37:42 UTC
Package python3-3.3.2-10.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing python3-3.3.2-10.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-2788/python3-3.3.2-10.fc20
then log in and leave karma (feedback).

Comment 4 John C Peterson 2014-02-23 19:01:20 UTC
Created attachment 866757 [details]
Update to original test script (#1066708), to more throughly test the fix.

The fix worked as expected for me. I am now able to load extension libraries from the sqlite3 module. (Positive Karma left on Bohdi).

I have attached an update to the test script I originally posted to demo the problem. It enables loading of extensions, and then loads the SpatiaLite extension library (/usr/lib64/libspatialite.so). You must have the libspatialite-devel RPM installed. Tests sqlite3 module for both Python 2.7.5 and Python 3.3.2

Comment 5 Fedora Update System 2014-02-24 12:27:40 UTC
python3-3.3.2-10.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.