本文整理匯總了Python中leap.soledad.client.sqlcipher.SQLCipherDatabase._factory方法的典型用法代碼示例。如果您正苦於以下問題:Python SQLCipherDatabase._factory方法的具體用法?Python SQLCipherDatabase._factory怎麽用?Python SQLCipherDatabase._factory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類leap.soledad.client.sqlcipher.SQLCipherDatabase
的用法示例。
在下文中一共展示了SQLCipherDatabase._factory方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: copy_sqlcipher_database_for_test
# 需要導入模塊: from leap.soledad.client.sqlcipher import SQLCipherDatabase [as 別名]
# 或者: from leap.soledad.client.sqlcipher.SQLCipherDatabase import _factory [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