Skip to content

Commit

Permalink
Feat(sqlite): Add driver supersqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
phdru committed Sep 22, 2019
1 parent d53e4f7 commit c78f887
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 14 deletions.
5 changes: 5 additions & 0 deletions docs/News.rst
Expand Up @@ -8,6 +8,11 @@ News
SQLObject (master)
==================

Features
--------

* Add driver ``supersqlite``.

SQLObject 3.7.3
===============

Expand Down
21 changes: 11 additions & 10 deletions docs/SQLObject.rst
Expand Up @@ -48,14 +48,14 @@ Requirements

Currently SQLObject supports MySQL_ via MySQLdb_ aka MySQL-python (called
mysqlclient_ for Python 3), `MySQL Connector`_, oursql_, PyMySQL_, PyODBC_
and PyPyODBC_. For PostgreSQL_ psycopg2_ is recommended;
PyGreSQL_, py-postgresql_ and pg8000_ are supported; SQLite_ has a
built-in driver or PySQLite_. Firebird_ is supported via fdb_ or
kinterbasdb_; pyfirebirdsql_ is supported but has problems. `MAX DB`_
(also known as SAP DB) is supported via sapdb_. Sybase via Sybase_. `MSSQL
Server`_ via pymssql_ (+ FreeTDS_) or adodbapi_ (Win32). PyODBC_ and
PyPyODBC_ are supported for MySQL, PostgreSQL and MSSQL but have
problems (not all tests passed).
and PyPyODBC_. For PostgreSQL_ psycopg2_ is recommended; PyGreSQL_,
py-postgresql_ and pg8000_ are supported; SQLite_ has a built-in driver,
PySQLite_ or supersqlite_. Firebird_ is supported via fdb_ or kinterbasdb_;
pyfirebirdsql_ is supported but has problems. `MAX DB`_ (also known as SAP
DB) is supported via sapdb_. Sybase via Sybase_. `MSSQL Server`_ via
pymssql_ (+ FreeTDS_) or adodbapi_ (Win32). PyODBC_ and PyPyODBC_ are
supported for MySQL, PostgreSQL and MSSQL but have problems (not all tests
passed).

.. _MySQL: https://www.mysql.com/
.. _MySQLdb: https://sourceforge.net/projects/mysql-python/
Expand All @@ -70,6 +70,7 @@ problems (not all tests passed).
.. _pg8000: https://pypi.org/project/pg8000/
.. _SQLite: https://sqlite.org/
.. _PySQLite: https://github.com/ghaering/pysqlite
.. _supersqlite: https://github.com/plasticityai/supersqlite
.. _Firebird: http://www.firebirdsql.org/en/python-driver/
.. _fdb: http://www.firebirdsql.org/en/devel-python-driver/
.. _kinterbasdb: http://kinterbasdb.sourceforge.net/
Expand Down Expand Up @@ -1857,8 +1858,8 @@ multi-threaded environment.
The user can choose a DB API driver for SQLite by using a ``driver``
parameter in DB URI or SQLiteConnection that can be a comma-separated list
of driver names. Possible drivers are: ``pysqlite2`` (alias ``sqlite2``),
``sqlite3``, ``sqlite`` (alias ``sqlite1``). Default is to test pysqlite2,
sqlite3 and sqlite in that order.
``sqlite3``, ``sqlite`` (alias ``sqlite1``), ``supersqlite``. Default is to
test supersqlite, pysqlite2, sqlite3 and sqlite in that order.

Connection-specific parameters are: ``encoding``, ``mode``, ``timeout``,
``check_same_thread``, ``use_table_info``.
Expand Down
7 changes: 6 additions & 1 deletion docs/download.rst
Expand Up @@ -76,10 +76,15 @@ PostgreSQL
psycopg2 psycopg postgres postgresql (synonyms for psycopg2)
pygresql pypostgresql py-postgresql pg8000

SQLite
^^^^^^

sqlite pysqlite supersqlite

The rest
^^^^^^^^

sapdb sqlite (pysqlite) sybase
sapdb sybase

Repositories
------------
Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -131,6 +131,7 @@
#
'sapdb': ['sapdb'],
'sqlite': ['pysqlite'],
'supersqlite': ['supersqlite'],
'sybase': ['Sybase'],
},
)
Expand Down
11 changes: 8 additions & 3 deletions sqlobject/sqlite/sqliteconnection.py
Expand Up @@ -32,13 +32,17 @@ class SQLiteConnection(DBAPI):
schemes = [dbName]

def __init__(self, filename, autoCommit=1, **kw):
drivers = kw.pop('driver', None) or 'pysqlite2,sqlite3,sqlite'
drivers = kw.pop('driver', None) or \
'supersqlite,pysqlite2,sqlite3,sqlite'
for driver in drivers.split(','):
driver = driver.strip()
if not driver:
continue
try:
if driver in ('sqlite2', 'pysqlite2'):
if driver == 'supersqlite':
from supersqlite import sqlite3 as sqlite
self.using_sqlite2 = True
elif driver in ('sqlite2', 'pysqlite2'):
from pysqlite2 import dbapi2 as sqlite
self.using_sqlite2 = True
elif driver == 'sqlite3':
Expand All @@ -50,7 +54,8 @@ def __init__(self, filename, autoCommit=1, **kw):
else:
raise ValueError(
'Unknown SQLite driver "%s", '
'expected pysqlite2, sqlite3 or sqlite' % driver)
'expected supersqlite, pysqlite2, sqlite3 '
'or sqlite' % driver)
except ImportError:
pass
else:
Expand Down
26 changes: 26 additions & 0 deletions tox.ini
Expand Up @@ -29,6 +29,7 @@ deps =
postgres-pg8000: git+https://github.com/sqlobject/pg8000.git@getuser#egg=pg8000
pyodbc: pyodbc
pypyodbc: pypyodbc
supersqlite: supersqlite
firebird-fdb: fdb
firebirdsql: firebirdsql
passenv = CI TRAVIS TRAVIS_* APPVEYOR DISTUTILS_USE_SDK MSSdk INCLUDE LIB PGPASSWORD WINDIR
Expand Down Expand Up @@ -423,6 +424,31 @@ commands = {[sqlite-memory]commands}
[testenv:py37-sqlite-memory]
commands = {[sqlite-memory]commands}

[sqlite-supersqlite]
commands =
{[testenv]commands}
-rm -f /tmp/sqlobject_test.sqdb
pytest --cov=sqlobject -D sqlite:///tmp/sqlobject_test.sqdb?driver=supersqlite&debug=1
rm -f /tmp/sqlobject_test.sqdb

[testenv:py27-sqlite-supersqlite]
commands =
easy_install -i https://downloads.egenix.com/python/index/ucs2/ egenix-mx-base
{[sqlite-supersqlite]commands}

[testenv:py34-sqlite-supersqlite]
commands = {[sqlite-supersqlite]commands}

[testenv:py35-sqlite-supersqlite]
commands = {[sqlite-supersqlite]commands}

[testenv:py36-sqlite-supersqlite]
commands = {[sqlite-supersqlite]commands}

[testenv:py37-sqlite-supersqlite]
commands = {[sqlite-supersqlite]commands}


# Firebird database test environments
[fdb]
commands =
Expand Down

0 comments on commit c78f887

Please sign in to comment.