.oO SearXNG Developer Documentation Oo.
|
Public Member Functions | |
__init__ (self, db_url) | |
sqlite3.Connection | connect (self) |
register_functions (self, conn) | |
sqlite3.Connection | DB (self) |
init (self) | |
create_schema (self, conn) | |
Public Attributes | |
db_url = db_url | |
properties = SQLiteProperties(db_url) | |
thread_local = threading.local() | |
Static Public Attributes | |
dict | DDL_CREATE_TABLES = {} |
int | DB_SCHEMA = 1 |
dict | SQLITE_THREADING_MODE |
str | SQLITE_JOURNAL_MODE = "WAL" |
dict | SQLITE_CONNECT_ARGS |
Protected Member Functions | |
_compatibility (self) | |
Protected Attributes | |
bool | _init_done = False |
_DB = None | |
Abstract base class for implementing convenient DB access in SQLite applications. In the constructor, a :py:obj:`SQLiteProperties` instance is already aggregated under ``self.properties``.
Definition at line 26 of file sqlitedb.py.
searx.sqlitedb.SQLiteAppl.__init__ | ( | self, | |
db_url ) |
Reimplemented in searx.favicons.cache.FaviconCacheSQLite, and searx.sqlitedb.SQLiteProperties.
Definition at line 88 of file sqlitedb.py.
|
protected |
Definition at line 96 of file sqlitedb.py.
References searx.sqlitedb.SQLiteAppl.SQLITE_THREADING_MODE.
sqlite3.Connection searx.sqlitedb.SQLiteAppl.connect | ( | self | ) |
Creates a new DB connection (:py:obj:`SQLITE_CONNECT_ARGS`). If not already done, the DB schema is set up
Definition at line 116 of file sqlitedb.py.
References searx.favicons.cache.FaviconCacheStats.__class__, searx.favicons.cache.FaviconCacheConfig.db_url, searx.sqlitedb.SQLiteAppl.db_url, searx.sqlitedb.SQLiteProperties.db_url, searx.sqlitedb.SQLiteAppl.init(), searx.sqlitedb.SQLiteProperties.init(), searx.sqlitedb.SQLiteAppl.register_functions(), searx.sqlitedb.SQLiteAppl.SQLITE_CONNECT_ARGS, and searx.sqlitedb.SQLiteProperties.SQLITE_CONNECT_ARGS.
Referenced by searx.sqlitedb.SQLiteAppl.DB(), and searx.favicons.cache.FaviconCacheSQLite.set().
searx.sqlitedb.SQLiteAppl.create_schema | ( | self, | |
conn ) |
Reimplemented in searx.sqlitedb.SQLiteProperties.
Definition at line 213 of file sqlitedb.py.
References searx.favicons.cache.FaviconCacheSQLite.DB_SCHEMA, searx.sqlitedb.SQLiteAppl.DB_SCHEMA, searx.favicons.cache.FaviconCacheSQLite.DDL_CREATE_TABLES, searx.sqlitedb.SQLiteAppl.DDL_CREATE_TABLES, and searx.sqlitedb.SQLiteAppl.properties.
Referenced by searx.sqlitedb.SQLiteAppl.init(), and searx.sqlitedb.SQLiteProperties.init().
sqlite3.Connection searx.sqlitedb.SQLiteAppl.DB | ( | self | ) |
Provides a DB connection. The connection is a *singleton* and therefore well suited for read access. If :py:obj:`SQLITE_THREADING_MODE` is ``serialized`` only one DB connection is created for all threads. .. note:: For dedicated `transaction control`_, it is recommended to create a new connection (:py:obj:`SQLiteAppl.connect`). .. _transaction control: https://docs.python.org/3/library/sqlite3.html#sqlite3-controlling-transactions
Definition at line 156 of file sqlitedb.py.
References searx.sqlitedb.SQLiteAppl.connect(), searx.sqlitedb.SQLiteAppl.thread_local, and searx.sqlitedb.SQLiteProperties.thread_local.
Referenced by searx.favicons.cache.FaviconCacheSQLite.__call__(), searx.sqlitedb.SQLiteProperties.__call__(), searx.favicons.cache.FaviconCacheSQLite._query_val(), searx.sqlitedb.SQLiteProperties.init(), searx.sqlitedb.SQLiteProperties.m_time(), searx.sqlitedb.SQLiteProperties.row(), and searx.sqlitedb.SQLiteProperties.set().
searx.sqlitedb.SQLiteAppl.init | ( | self | ) |
Initializes the DB schema and properties, is only executed once even if called several times.
Reimplemented in searx.sqlitedb.SQLiteProperties.
Definition at line 193 of file sqlitedb.py.
References searx.sqlitedb.SQLiteAppl._init_done, searx.sqlitedb.SQLiteProperties._init_done, searx.sqlitedb.SQLiteAppl.create_schema(), searx.sqlitedb.SQLiteProperties.create_schema(), searx.favicons.cache.FaviconCacheSQLite.DB_SCHEMA, searx.sqlitedb.SQLiteAppl.DB_SCHEMA, searx.favicons.cache.FaviconCacheConfig.db_url, searx.sqlitedb.SQLiteAppl.db_url, searx.sqlitedb.SQLiteProperties.db_url, and searx.sqlitedb.SQLiteAppl.properties.
Referenced by searx.sqlitedb.SQLiteAppl.connect().
searx.sqlitedb.SQLiteAppl.register_functions | ( | self, | |
conn ) |
Create user-defined_ SQL functions. ``REGEXP(<pattern>, <field>)`` : 0 | 1 `re.search`_ returns (int) 1 for a match and 0 for none match of ``<pattern>`` in ``<field>``. .. code:: sql SELECT '12' AS field WHERE REGEXP('^[0-9][0-9]$', field) -- 12 SELECT REGEXP('[0-9][0-9]', 'X12Y') -- 1 SELECT REGEXP('[0-9][0-9]', 'X1Y') -- 0 .. _user-defined: https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.create_function .. _deterministic: https://sqlite.org/deterministic.html .. _re.search: https://docs.python.org/3/library/re.html#re.search
Definition at line 131 of file sqlitedb.py.
Referenced by searx.sqlitedb.SQLiteAppl.connect().
|
protected |
Definition at line 99 of file sqlitedb.py.
|
protected |
Definition at line 93 of file sqlitedb.py.
Referenced by searx.sqlitedb.SQLiteAppl.init(), and searx.sqlitedb.SQLiteProperties.init().
|
static |
Definition at line 33 of file sqlitedb.py.
Referenced by searx.sqlitedb.SQLiteAppl.create_schema(), and searx.sqlitedb.SQLiteAppl.init().
searx.sqlitedb.SQLiteAppl.db_url = db_url |
Definition at line 90 of file sqlitedb.py.
Referenced by searx.sqlitedb.SQLiteAppl.connect(), searx.sqlitedb.SQLiteAppl.init(), and searx.sqlitedb.SQLiteProperties.init().
|
static |
Definition at line 31 of file sqlitedb.py.
Referenced by searx.sqlitedb.SQLiteAppl.create_schema().
searx.sqlitedb.SQLiteAppl.properties = SQLiteProperties(db_url) |
Definition at line 91 of file sqlitedb.py.
Referenced by searx.sqlitedb.SQLiteAppl.create_schema(), searx.sqlitedb.SQLiteAppl.init(), and searx.favicons.cache.FaviconCacheSQLite.next_maintenance_time().
|
static |
Definition at line 54 of file sqlitedb.py.
Referenced by searx.sqlitedb.SQLiteAppl.connect().
|
static |
Definition at line 53 of file sqlitedb.py.
|
static |
Definition at line 38 of file sqlitedb.py.
Referenced by searx.sqlitedb.SQLiteAppl._compatibility().
searx.sqlitedb.SQLiteAppl.thread_local = threading.local() |
Definition at line 92 of file sqlitedb.py.
Referenced by searx.sqlitedb.SQLiteAppl.DB().