本文整理汇总了Python中leap.soledad.client.sqlcipher.SQLCipherDatabase._db_handle方法的典型用法代码示例。如果您正苦于以下问题:Python SQLCipherDatabase._db_handle方法的具体用法?Python SQLCipherDatabase._db_handle怎么用?Python SQLCipherDatabase._db_handle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leap.soledad.client.sqlcipher.SQLCipherDatabase
的用法示例。
在下文中一共展示了SQLCipherDatabase._db_handle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy_sqlcipher_database_for_test
# 需要导入模块: from leap.soledad.client.sqlcipher import SQLCipherDatabase [as 别名]
# 或者: from leap.soledad.client.sqlcipher.SQLCipherDatabase import _db_handle [as 别名]
def copy_sqlcipher_database_for_test(test, db):
# DO NOT COPY OR REUSE THIS CODE OUTSIDE TESTS: COPYING U1DB DATABASES IS
# THE WRONG THING TO DO, THE ONLY REASON WE DO SO HERE IS TO TEST THAT WE
# CORRECTLY DETECT IT HAPPENING SO THAT WE CAN RAISE ERRORS RATHER THAN
# CORRUPT USER DATA. USE SYNC INSTEAD, OR WE WILL SEND NINJA TO YOUR
# HOUSE.
new_db = SQLCipherDatabase(':memory:', PASSWORD)
tmpfile = StringIO()
for line in db._db_handle.iterdump():
if not 'sqlite_sequence' in line: # work around bug in iterdump
tmpfile.write('%s\n' % line)
tmpfile.seek(0)
new_db._db_handle = dbapi2.connect(':memory:')
new_db._db_handle.cursor().executescript(tmpfile.read())
new_db._db_handle.commit()
new_db._set_replica_uid(db._replica_uid)
new_db._factory = db._factory
return new_db