|
def | __init__ (self, filename=':memory:', flags='r', mode=None) |
|
def | __len__ (self) |
|
def | __bool__ (self) |
|
def | keys (self) |
|
def | values (self) |
|
def | items (self) |
|
def | __iter__ (self) |
|
def | iterkeys (self) |
|
def | itervalues (self) |
|
def | iteritems (self) |
|
def | __contains__ (self, key) |
|
def | __getitem__ (self, key) |
|
def | __setitem__ (self, key, value) |
|
def | __delitem__ (self, key) |
|
def | update (self, items=(), **kwds) |
|
def | clear (self) |
|
def | sync (self) |
|
def | close (self) |
|
def | __del__ (self) |
|
Definition at line 28 of file dbsqlite.py.
◆ __init__()
def python.dbsqlite.SQLhash.__init__ |
( |
|
self, |
|
|
|
filename = ':memory:' , |
|
|
|
flags = 'r' , |
|
|
|
mode = None |
|
) |
| |
Definition at line 29 of file dbsqlite.py.
29 def __init__(self, filename=':memory:
', flags='r', mode=None):
36 if os.path.exists(filename):
39 MAKE_SHELF =
'CREATE TABLE IF NOT EXISTS shelf (key TEXT PRIMARY KEY NOT NULL, value BLOB)'
40 self.conn = sqlite3.connect(filename)
41 self.conn.text_factory = str
42 if 'r' not in flags
or filename==
':memory:':
◆ __del__()
def python.dbsqlite.SQLhash.__del__ |
( |
|
self | ) |
|
◆ __bool__()
def python.dbsqlite.SQLhash.__bool__ |
( |
|
self | ) |
|
Definition at line 51 of file dbsqlite.py.
53 GET_BOOL =
'SELECT MAX(ROWID) FROM shelf'
54 return self.conn.
execute(GET_BOOL).fetchone()[0]
is not None
◆ __contains__()
def python.dbsqlite.SQLhash.__contains__ |
( |
|
self, |
|
|
|
key |
|
) |
| |
Definition at line 80 of file dbsqlite.py.
81 HAS_ITEM =
'SELECT 1 FROM shelf WHERE key = ?'
82 return self.conn.
execute(HAS_ITEM, (key,)).fetchone()
is not None
◆ __delitem__()
def python.dbsqlite.SQLhash.__delitem__ |
( |
|
self, |
|
|
|
key |
|
) |
| |
Definition at line 98 of file dbsqlite.py.
98 def __delitem__(self, key):
101 DEL_ITEM =
'DELETE FROM shelf WHERE key = ?'
102 self.conn.
execute(DEL_ITEM, (key,))
◆ __getitem__()
def python.dbsqlite.SQLhash.__getitem__ |
( |
|
self, |
|
|
|
key |
|
) |
| |
Definition at line 84 of file dbsqlite.py.
85 GET_ITEM =
'SELECT value FROM shelf WHERE key = ?'
86 item = self.conn.
execute(GET_ITEM, (key,)).fetchone()
90 return pickle.loads(item[0])
◆ __iter__()
def python.dbsqlite.SQLhash.__iter__ |
( |
|
self | ) |
|
Definition at line 65 of file dbsqlite.py.
66 return self.iterkeys()
◆ __len__()
def python.dbsqlite.SQLhash.__len__ |
( |
|
self | ) |
|
Definition at line 47 of file dbsqlite.py.
48 GET_LEN =
'SELECT COUNT(*) FROM shelf'
49 return self.conn.
execute(GET_LEN).fetchone()[0]
◆ __setitem__()
def python.dbsqlite.SQLhash.__setitem__ |
( |
|
self, |
|
|
|
key, |
|
|
|
value |
|
) |
| |
Definition at line 92 of file dbsqlite.py.
93 ADD_ITEM =
'REPLACE INTO shelf (key, value) VALUES (?,?)'
94 value = pickle.dumps(value)
95 self.conn.
execute(ADD_ITEM, (key, value))
◆ clear()
def python.dbsqlite.SQLhash.clear |
( |
|
self | ) |
|
Definition at line 118 of file dbsqlite.py.
119 CLEAR_ALL =
'DELETE FROM shelf; VACUUM;'
120 self.conn.executescript(CLEAR_ALL)
◆ close()
def python.dbsqlite.SQLhash.close |
( |
|
self | ) |
|
Definition at line 127 of file dbsqlite.py.
128 if self.conn
is not None:
◆ items()
def python.dbsqlite.SQLhash.items |
( |
|
self | ) |
|
◆ iteritems()
def python.dbsqlite.SQLhash.iteritems |
( |
|
self | ) |
|
Definition at line 76 of file dbsqlite.py.
77 GET_ITEMS =
'SELECT key, value FROM shelf ORDER BY ROWID'
78 return SQLHashItemIterator(self.conn, GET_ITEMS, (0, 1))
◆ iterkeys()
def python.dbsqlite.SQLhash.iterkeys |
( |
|
self | ) |
|
Definition at line 68 of file dbsqlite.py.
69 GET_KEYS =
'SELECT key FROM shelf ORDER BY ROWID'
70 return SQLHashKeyIterator(self.conn, GET_KEYS, (0,))
◆ itervalues()
def python.dbsqlite.SQLhash.itervalues |
( |
|
self | ) |
|
Definition at line 72 of file dbsqlite.py.
73 GET_VALUES =
'SELECT value FROM shelf ORDER BY ROWID'
74 return SQLHashValueIterator(self.conn, GET_VALUES, (0,))
◆ keys()
def python.dbsqlite.SQLhash.keys |
( |
|
self | ) |
|
◆ sync()
def python.dbsqlite.SQLhash.sync |
( |
|
self | ) |
|
Definition at line 123 of file dbsqlite.py.
124 if self.conn
is not None:
◆ update()
def python.dbsqlite.SQLhash.update |
( |
|
self, |
|
|
|
items = () , |
|
|
** |
kwds |
|
) |
| |
Definition at line 105 of file dbsqlite.py.
105 def update(self, items=(), **kwds):
107 items = items.items()
108 items = [(k,pickle.dumps(v))
for k,v
in items]
109 except AttributeError:
112 UPDATE_ITEMS =
'REPLACE INTO shelf (key, value) VALUES (?, ?)'
113 self.conn.executemany(UPDATE_ITEMS, items)
◆ values()
def python.dbsqlite.SQLhash.values |
( |
|
self | ) |
|
◆ conn
python.dbsqlite.SQLhash.conn |
The documentation for this class was generated from the following file: