当前位置: 首页>>代码示例>>Python>>正文


Python SQLiteCacheDB.getInstance方法代码示例

本文整理汇总了Python中Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python SQLiteCacheDB.getInstance方法的具体用法?Python SQLiteCacheDB.getInstance怎么用?Python SQLiteCacheDB.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB的用法示例。


在下文中一共展示了SQLiteCacheDB.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tearDown

# 需要导入模块: from Tribler.Core.CacheDB.sqlitecachedb import SQLiteCacheDB [as 别名]
# 或者: from Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB import getInstance [as 别名]
    def tearDown(self):
        if SQLiteCacheDB.hasInstance():
            SQLiteCacheDB.getInstance().close_all()
            SQLiteCacheDB.delInstance()

        if Session.has_instance():  # Upgrading will create a session instance
            Session.del_instance()

        sqlitecachedb.INITIAL_UPGRADE_PAUSE, sqlitecachedb.SUCCESIVE_UPGRADE_PAUSE, sqlitecachedb.UPGRADE_BATCH_SIZE, sqlitecachedb.TEST_OVERRIDE = self.original_values
        self.tearDownCleanup()
开发者ID:Anbcorp,项目名称:tribler,代码行数:12,代码来源:test_sqlitecachedb_upgrade.py

示例2: tearDown

# 需要导入模块: from Tribler.Core.CacheDB.sqlitecachedb import SQLiteCacheDB [as 别名]
# 或者: from Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB import getInstance [as 别名]
    def tearDown(self):
        self.torrentChecking.shutdown()
        TorrentChecking.delInstance()

        if SQLiteCacheDB.hasInstance():
            SQLiteCacheDB.getInstance().close_all()
            SQLiteCacheDB.delInstance()

        TorrentDBHandler.delInstance()
        MyPreferenceDBHandler.delInstance()
        NetworkBuzzDBHandler.delInstance()

        self.tearDownCleanup()
开发者ID:Anbcorp,项目名称:tribler,代码行数:15,代码来源:test_tracker_checking.py

示例3: read_data

# 需要导入模块: from Tribler.Core.CacheDB.sqlitecachedb import SQLiteCacheDB [as 别名]
# 或者: from Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB import getInstance [as 别名]
    def read_data(self):
        db = SQLiteCacheDB.getInstance()
        one = db.fetchone('select * from person')
        assert one == ('a','b'), str(one)

        one = db.fetchone("select lastname from person where firstname == 'b'")
        assert one == 'a'

        one = db.fetchone("select lastname from person where firstname == 'c'")
        assert one == None

        all = db.fetchall('select * from person')
        assert len(all) == 101, len(all)

        num = db.size('person')
        assert num == 101

        db.insert('person', lastname='1', firstname='abc')
        one = db.fetchone("select firstname from person where lastname == '1'")
        assert one == '1' or one == 'abc'
        all = db.fetchall("select firstname from person where lastname == '1'")
        assert len(all) == 2

        db.update('person', "lastname == '2'", firstname='56')
        one = db.fetchone("select firstname from person where lastname == '2'")
        assert one == '56', one

        db.update('person', "lastname == '3'", firstname=65)
        one = db.fetchone("select firstname from person where lastname == '3'")
        assert one == 65, one

        db.update('person', "lastname == '4'", firstname=654, lastname=44)
        one = db.fetchone("select firstname from person where lastname == 44")
        assert one == 654, one
        db.close()
开发者ID:Devristo,项目名称:tribler,代码行数:37,代码来源:test_sqlitecachedb.py

示例4: test_open_close_db

# 需要导入模块: from Tribler.Core.CacheDB.sqlitecachedb import SQLiteCacheDB [as 别名]
# 或者: from Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB import getInstance [as 别名]
 def test_open_close_db(self):
     sqlite_test = SQLiteCacheDB.getInstance()
     sqlite_test.openDB(self.db_path, 1250)
     sqlite_test.close()
     sqlite_test.close()
     sqlite_test.openDB(self.db_path, 0)
     sqlite_test.close()
开发者ID:Devristo,项目名称:tribler,代码行数:9,代码来源:test_sqlitecachedb.py

示例5: __init__

# 需要导入模块: from Tribler.Core.CacheDB.sqlitecachedb import SQLiteCacheDB [as 别名]
# 或者: from Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB import getInstance [as 别名]
    def __init__(self):
        self._sqlite_cache_db = SQLiteCacheDB.getInstance()

        crawler = Crawler.get_instance()
        if crawler.am_crawler():
            msg = "# Crawler started" 
            self.__log(msg)
开发者ID:egbertbouman,项目名称:tribler-g,代码行数:9,代码来源:UserEventLogCrawler.py

示例6: keep_reading_data

# 需要导入模块: from Tribler.Core.CacheDB.sqlitecachedb import SQLiteCacheDB [as 别名]
# 或者: from Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB import getInstance [as 别名]
            def keep_reading_data(self, period):
                db = SQLiteCacheDB.getInstance()
                st = time()
                oldnum = 0
                self.all = []
                self.read_times = 0
                if DEBUG_R:
                    print "begin read", self.getName(), period, time()
                while True:
                    et = time()
                    if et-st > period:
                        break
                    if DEBUG_R:
                        print "...start read", self.getName(), time()
                        sys.stdout.flush()

                    try:
                        self.all = db.fetchall("select * from person")
                        self.last_read = time()-st
                        self.read_times += 1
                    except Exception, msg:
                        print_exc()
                        print "*-*", Exception, msg
                        self.read_locks += 1
                        if DEBUG:
                            print >> sys.stdout, "Locked while reading!", self.read_locks
                            sys.stdout.flush()
                    else:
                        if DEBUG_R:
                            print "...end read", self.getName(), time(), len(self.all)
                            sys.stdout.flush()
开发者ID:Devristo,项目名称:tribler,代码行数:33,代码来源:test_sqlitecachedb.py

示例7: setUp

# 需要导入模块: from Tribler.Core.CacheDB.sqlitecachedb import SQLiteCacheDB [as 别名]
# 或者: from Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB import getInstance [as 别名]
 def setUp(self):
     db_path = TRIBLER_DB_PATH
     db = SQLiteCacheDB.getInstance()
     db.initDB(db_path, busytimeout=BUSYTIMEOUT)
     launchmany = FakeLaunchmany(db)
     overlay_bridge = FakeOverlayBridge()
     self.datahandler = DataHandler(launchmany,overlay_bridge)
开发者ID:duy,项目名称:tribler,代码行数:9,代码来源:test_buddycast.py

示例8: setUp

# 需要导入模块: from Tribler.Core.CacheDB.sqlitecachedb import SQLiteCacheDB [as 别名]
# 或者: from Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB import getInstance [as 别名]
    def setUp(self):
        self.setUpCleanup()

        dbpath = init_bak_tribler_sdb('bak_new_tribler.sdb', destination_path=self.getStateDir(), overwrite=True)
        self.sqlitedb = SQLiteCacheDB.getInstance()
        self.sqlitedb.initDB(dbpath, busytimeout=BUSYTIMEOUT)
        self.sqlitedb.waitForUpdateComplete()
开发者ID:Anbcorp,项目名称:tribler,代码行数:9,代码来源:test_sqlitecachedbhandler.py

示例9: setUp

# 需要导入模块: from Tribler.Core.CacheDB.sqlitecachedb import SQLiteCacheDB [as 别名]
# 或者: from Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB import getInstance [as 别名]
 def setUp(self):
     db_path = TRIBLER_DB_PATH
     db = SQLiteCacheDB.getInstance()
     db.openDB(db_path, lib=LIB, autocommit=AUTOCOMMIT, busytimeout=BUSYTIMEOUT)
     self.sp1 = '0R0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\x1a\x03>\x00\x04\x00\\\xdfXv\xffX\xf2\xfe\x96\xe1_]\xf5\x1b\xb4\x91\x91\xa5I\xf0nl\x81\xd2A\xfb\xb7u)\x01T\xa9*)r\x9b\x81s\xb7j\xd2\xecrSg$;\xc8"7s\xecSF\xd3\x0bgK\x1c'
     self.sp2 = '0R0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\x1a\x03>\x00\x04\x01\xdb\x80+O\xd9N7`\xfc\xd3\xdd\xf0 \xfdC^\xc9\[email protected]\x97\xaa\x91r\x1c\xdeL\xf2n\x9f\x00U\xc1A\xf9Ae?\xd8t}_c\x08\xb3G\[email protected]! \xa0\x90M\xfb\xca\[email protected]'
     self.fr1 = str2bin('MFIwEAYHKoZIzj0CAQYFK4EEABoDPgAEAL/l2IyVa6lc3KAqQyEnR++rIzi+AamnbzXHCxOFAFy67COiBhrC79PLzzUiURbHDx21QA4p8w3UDHLA')
开发者ID:nomadsummer,项目名称:cs198mojo,代码行数:9,代码来源:test_sqlitecachedbhandler.py

示例10: keep_writing_data

# 需要导入模块: from Tribler.Core.CacheDB.sqlitecachedb import SQLiteCacheDB [as 别名]
# 或者: from Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB import getInstance [as 别名]
            def keep_writing_data(self, period, num_write, commit=False):
                db = SQLiteCacheDB.getInstance()
                st = time()
                if DEBUG:
                    print "begin write", self.getName(), period, time()
                    sys.stdout.flush()
                begin_time = time()
                w_times = []
                c_times = []
                self.last_write = 0
                try:
                    while True:
                        st = time()
                        if st-begin_time > period:
                            break
                        #db.begin()
                        values = []

                        for i in range(num_write):
                            value = (str(i)+'"'+"'", str(i**2)+'"'+"'")
                            values.append(value)

                        try:
                            st = time()
                            if DEBUG:
                                print '-'+self.num + "start write", self.getName(), self.writes, time()-begin_time
                                sys.stdout.flush()

                            sql = 'INSERT INTO person VALUES (?, ?)'
                            db.executemany(sql, values, commit=commit)
                            self.last_write = time()-begin_time

                            write_time = time()-st
                            w_times.append(write_time)
                            if DEBUG:
                                print '-'+self.num + "end write", self.getName(), '+', write_time
                                sys.stdout.flush()
                            self.writes += 1
                        except apsw.BusyError:
                            self.write_locks += 1
                            if DEBUG:
                                if commit:
                                    s = "Writing/Commiting"
                                else:
                                    s = "Writing"
                                print >> sys.stdout, '>'+self.num + "Locked while ", s, self.getName(), self.write_locks, time()-st
                                sys.stdout.flush()
                            continue

                        if SLEEP_W >= 0:
                            sleep(SLEEP_W/1000.0)

                        if DO_STH > 0:
                            do_sth(DO_STH)

                except Exception, msg:
                    print_exc()
                    print >> sys.stderr, "On Error", time(), begin_time, time()-begin_time, Exception, msg, self.getName()
开发者ID:Devristo,项目名称:tribler,代码行数:60,代码来源:test_sqlitecachedb.py

示例11: __init__

# 需要导入模块: from Tribler.Core.CacheDB.sqlitecachedb import SQLiteCacheDB [as 别名]
# 或者: from Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB import getInstance [as 别名]
    def __init__(self):
        self._sqlite_cache_db = SQLiteCacheDB.getInstance()

        crawler = Crawler.get_instance()
        if crawler.am_crawler():
            self._file = open("databasecrawler.txt", "a")
            self._file.write("".join(("# ", "*" * 80, "\n# ", strftime("%Y/%m/%d %H:%M:%S"), " Crawler started\n")))
            self._file.flush()
        else:
            self._file = None
开发者ID:ebcayabyab-personal,项目名称:swiftarm,代码行数:12,代码来源:DatabaseCrawler.py

示例12: create_db

# 需要导入模块: from Tribler.Core.CacheDB.sqlitecachedb import SQLiteCacheDB [as 别名]
# 或者: from Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB import getInstance [as 别名]
 def create_db(self, db_path, busytimeout=DEFAULT_BUSY_TIMEOUT):
     create_sql = "create table person(lastname, firstname);"
     db = SQLiteCacheDB.getInstance()
     tmp_sql_path = 'tmp.sql'
     f = open(tmp_sql_path, 'w')
     f.write(create_sql)
     f.close()
     #print "initDB", db_path
     db.initDB(db_path, tmp_sql_path, busytimeout=busytimeout, check_version=False)
     os.remove(tmp_sql_path)
开发者ID:Devristo,项目名称:tribler,代码行数:12,代码来源:test_sqlitecachedb.py

示例13: setUp

# 需要导入模块: from Tribler.Core.CacheDB.sqlitecachedb import SQLiteCacheDB [as 别名]
# 或者: from Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB import getInstance [as 别名]
 def setUp(self):
     self.db = SQLiteCacheDB.getInstance()
     self.db.initDB(TRIBLER_DB_PATH_BACKUP, lib=0)
     permid = {}
     permid[3127] = 'MFIwEAYHKoZIzj0CAQYFK4EEABoDPgAEAcPezgQ13k1MSOaUrCPisWRhYuNT7Tm+q5rUgHFvAWd9b+BcSut6TCniEgHYHDnQ6TH/vxQBqtY8Loag'
     permid[994] = 'MFIwEAYHKoZIzj0CAQYFK4EEABoDPgAEAJUNmwvDaigRaM4cj7cE2O7lessqnnFEQsan7df9AZS8xeNmVsP/XXVrEt4t7e2TNicYmjn34st/sx2P'
     permid[19] = 'MFIwEAYHKoZIzj0CAQYFK4EEABoDPgAEAAJv2YLuIWa4QEdOEs4CPRxQZDwZphKd/xK/tgbcALG198nNdT10znJ2sZYl+OJIvj7YfYp75PrrnWNX'
     permid[5] = 'MFIwEAYHKoZIzj0CAQYFK4EEABoDPgAEAAB0XbUrw5b8CrTrMZST1SPyrzjgSzIE6ynALtlZASGAb+figVXRRGpKW6MSal3KnEm1/q0P3JPWrhCE'
     self.permid = permid
     
     db = MyPreferenceDBHandler.getInstance()
     db.loadData()
开发者ID:nomadsummer,项目名称:cs198mojo,代码行数:14,代码来源:test_torrentcollecting.py

示例14: tearDown

# 需要导入模块: from Tribler.Core.CacheDB.sqlitecachedb import SQLiteCacheDB [as 别名]
# 或者: from Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB import getInstance [as 别名]
    def tearDown(self):
        self.annotate(self._testMethodName, start=False)

        """ unittest test tear down code """
        if self.session is not None:
            self._shutdown_session(self.session)
            Session.del_instance()

        time.sleep(10)
        gc.collect()

        ts = enumerate_threads()
        print >> sys.stderr, "test_as_server: Number of threads still running", len(ts)
        for t in ts:
            print >> sys.stderr, "test_as_server: Thread still running", t.getName(), "daemon", t.isDaemon(), "instance:", t

        if SQLiteCacheDB.hasInstance():
            SQLiteCacheDB.getInstance().close_all()
            SQLiteCacheDB.delInstance()

        self.tearDownCleanup()
开发者ID:Anbcorp,项目名称:tribler,代码行数:23,代码来源:test_as_server.py

示例15: write_data

# 需要导入模块: from Tribler.Core.CacheDB.sqlitecachedb import SQLiteCacheDB [as 别名]
# 或者: from Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB import getInstance [as 别名]
 def write_data(self):
     db = SQLiteCacheDB.getInstance()
     #db.begin()
     db.insert('person', lastname='a', firstname='b')
     values = []
     for i in range(100):
         value = (str(i), str(i**2))
         values.append(value)
     db.insertMany('person', values)
     db.commit()
     #db.begin()
     db.commit()
     db.commit()
     db.close()
开发者ID:Devristo,项目名称:tribler,代码行数:16,代码来源:test_sqlitecachedb.py


注:本文中的Tribler.Core.CacheDB.sqlitecachedb.SQLiteCacheDB.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。