當前位置: 首頁>>代碼示例>>Python>>正文


Python SQLCipherDatabase._db_handle方法代碼示例

本文整理匯總了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
開發者ID:fbernitt,項目名稱:soledad,代碼行數:20,代碼來源:util.py


注:本文中的leap.soledad.client.sqlcipher.SQLCipherDatabase._db_handle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。