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)
| 36 | SQLITE = "sqlite" |
| 37 | |
| 38 | def _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 | |
| 56 | def find(match=lambda item: False, list=[]): |
| 57 | """ Returns the first item in the list for which match(item) is True. |
no outgoing calls
no test coverage detected
searching dependent graphs…