Bug 1066708 - 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: python
Version: 20
Hardware: All
OS: Unspecified
unspecified
medium
Target Milestone: ---
Assignee: Bohuslav "Slavek" Kabrda
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 814905 (view as bug list)
Depends On:
Blocks: 1066938
TreeView+ depends on / blocked
 
Reported: 2014-02-18 23:17 UTC by John C Peterson
Modified: 2014-02-25 11:34 UTC (History)
8 users (show)

Fixed In Version: python-2.7.5-11.fc20
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1066938 (view as bug list)
Environment:
Last Closed: 2014-02-24 12:31:46 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Bourne shell script to reproduce, demonstrate the problem (1.05 KB, application/x-shellscript)
2014-02-18 23:17 UTC, John C Peterson
no flags Details
Proposed patch for the Python SRPM (617 bytes, patch)
2014-02-18 23:20 UTC, John C Peterson
no flags Details | Diff
Update to original test script, to more throughly test the fix. (2.47 KB, application/x-shellscript)
2014-02-23 18:57 UTC, John C Peterson
no flags Details

Description John C Peterson 2014-02-18 23:17:01 UTC
Created attachment 864823 [details]
Bourne shell script to reproduce, demonstrate the problem

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

Comment 1 John C Peterson 2014-02-18 23:20:55 UTC
Created attachment 864825 [details]
Proposed patch for the Python SRPM

Comment 2 Bohuslav "Slavek" Kabrda 2014-02-19 10:57:48 UTC
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 3 Fedora Update System 2014-02-19 15:39:32 UTC
python-2.7.5-11.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/python-2.7.5-11.fc20

Comment 4 Fedora Update System 2014-02-22 00:39:58 UTC
Package python-2.7.5-11.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 python-2.7.5-11.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-2796/python-2.7.5-11.fc20
then log in and leave karma (feedback).

Comment 5 John C Peterson 2014-02-23 18:57:16 UTC
Created attachment 866746 [details]
Update to original test script, 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 that enables loading of extensions, and then loads the SpatiaLite extension library (/usr/lib64/libspatialite.so). You must have the libspatialite-devel RPM installed.

Comment 6 Fedora Update System 2014-02-24 12:31:46 UTC
python-2.7.5-11.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 7 Bohuslav "Slavek" Kabrda 2014-02-25 11:34:10 UTC
*** Bug 814905 has been marked as a duplicate of this bug. ***


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