MCPcopy Index your code
hub / github.com/clips/pattern / _import_db

Function _import_db

pattern/db/__init__.py:38–54  ·  view source on GitHub ↗

Lazy import called from Database() or Database.new(). Depending on the type of database we either import MySQLdb or SQLite. Note: 64-bit Python needs 64-bit MySQL, 32-bit the 32-bit version.

(engine=SQLITE)

Source from the content-addressed store, hash-verified

36SQLITE = "sqlite"
37
38def _import_db(engine=SQLITE):
39 """ Lazy import called from Database() or Database.new().
40 Depending on the type of database we either import MySQLdb or SQLite.
41 Note: 64-bit Python needs 64-bit MySQL, 32-bit the 32-bit version.
42 """
43 global MySQLdb
44 global sqlite
45 if engine == MYSQL:
46 import MySQLdb
47 warnings.simplefilter("ignore", MySQLdb.Warning)
48 if engine == SQLITE:
49 try:
50 # Python 2.5+
51 import sqlite3.dbapi2 as sqlite
52 except:
53 # Python 2.4 with pysqlite2
54 import pysqlite2.dbapi2 as sqlite
55
56def find(match=lambda item: False, list=[]):
57 """ Returns the first item in the list for which match(item) is True.

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…