我们从Python开源项目中,提取了以下25个代码示例,用于说明如何使用sqlite3.PrepareProtocol()。
def __conform__(self, protocol): if protocol is sqlite.PrepareProtocol: return self.val else: return None
def tearDown(self): del sqlite.adapters[(int, sqlite.PrepareProtocol)] self.cur.close() self.con.close()
def register_adapter(type_, function): adapters[(type_, sqlite3.PrepareProtocol)] = function
def _adapt_from_python(value): if not isinstance(value, basestring): adapter_key = (type(value), sqlite3.PrepareProtocol) adapter = adapters.get(adapter_key) try: if adapter is None: # Fall back to _default_adapters, so that ObjectAdaptationTests # teardown will correctly restore the default state. adapter = _default_adapters[adapter_key] except KeyError as e: # No adapter registered. Let the object adapt itself via PEP-246. # It has been rejected by the BDFL, but is still implemented # on stdlib sqlite3 module even on Python 3 !! if hasattr(value, '__adapt__'): adapted = value.__adapt__(sqlite3.PrepareProtocol) elif hasattr(value, '__conform__'): adapted = value.__conform__(sqlite3.PrepareProtocol) else: raise InterfaceError(e) else: adapted = adapter(value) else: adapted = value # The adapter could had returned a string if isinstance(adapted, (bytes, unicode)): adapted = _escape_string(adapted) elif adapted is None: adapted = 'NULL' else: adapted = str(adapted) return adapted
def __conform__(self, protocol): if protocol is sqlite3.PrepareProtocol: return "%f;%f" % (self.x, self.y)