Example #1
0
    def test_copy_db(self):
        ''' test copy db
        '''
        def transform(item):
            return item
        
        source = [Product, 'tests/db/copy-db-source.sqlite']
        if os.path.isfile(source[1]):
            os.remove(source[1])
        target = [Product, 'tests/db/copy-db-target.sqlite']
        if os.path.isfile(target[1]):
            os.remove(target[1])
        source[1] = URI_TEMPLATE.format(source[1], 'test')
        target[1] = URI_TEMPLATE.format(target[1], 'test')

        ds = dblite.open(source[0], source[1])
        for i in range(3):
            ds.put(Product({'name': 'product#%d' % i}))
        ds.commit()
        ds.close()
        
        dblite.copy(source, target, transform=transform)
        
        ds = dblite.open(target[0], target[1])
        self.assertEqual(len(ds), 3)
Example #2
0
    def test_copy_db(self):
        ''' test copy db
        '''
        def transform(item):
            return item

        source = [Product, 'tests/db/copy-db-source.sqlite']
        if os.path.isfile(source[1]):
            os.remove(source[1])
        target = [Product, 'tests/db/copy-db-target.sqlite']
        if os.path.isfile(target[1]):
            os.remove(target[1])
        source[1] = URI_TEMPLATE.format(source[1], 'test')
        target[1] = URI_TEMPLATE.format(target[1], 'test')

        ds = dblite.open(source[0], source[1])
        for i in range(3):
            ds.put(Product({'name': 'product#%d' % i}))
        ds.commit()
        ds.close()

        dblite.copy(source, target, transform=transform)

        ds = dblite.open(target[0], target[1])
        self.assertEqual(len(ds), 3)
Example #3
0
    def test_enter_exit(self):

        uri = 'sqlite://tests/db/db-enter-exit.sqlite:test'

        with dblite.open(Product, uri) as ds:
            ds.put(Product({'name': 'product_name', 'price': 100}))
            self.assertTrue(isinstance(ds.get(limit=1), Product))

        self.assertEqual(ds.get(limit=1), None)
Example #4
0
    def test_open_storage(self):
        ''' test open storage
        '''
        uri = 'sqlite://tests/db/db-open.sqlite:test'

        ds = dblite.open(Product, uri)
        ds.put(Product({'name': 'product_name', 'price': 100}))
        self.assertTrue(isinstance(ds.get(limit=1), Product))
        ds.close()
Example #5
0
    def test_enter_exit(self):

        uri = 'sqlite://tests/db/db-enter-exit.sqlite:test'

        with dblite.open(Product, uri) as ds:
            ds.put(Product({'name': 'product_name', 'price': 100}))
            self.assertTrue(isinstance(ds.get(limit=1), Product))

        self.assertEqual(ds.get(limit=1), None)
Example #6
0
    def test_open_storage(self):
        ''' test open storage
        '''
        uri = 'sqlite://tests/db/db-open.sqlite:test'

        ds = dblite.open(Product, uri)
        ds.put(Product({'name': 'product_name', 'price': 100}))
        self.assertTrue(isinstance(ds.get(limit=1), Product))
        ds.close()
Example #7
0
    def open_spider(self, spider):
        """Prepare database for spider.

        Parameters
        ----------
        spider : Spider
            The spider the databse is opened for.
        """
        self.datastore = dblite.open(
            Record,
            "sqlite://" + expanduser(CONFIGS['databases']['local']['PATH']),
            autocommit=10000)
Example #8
0
    def open_spider(self,spider):
        try:
            self.ds=dblite.open(DmmItem,'sqlite://db/video.sqlite:data_videos',autocommit=True)
            self.ds_actor=dblite.open(ActorItem,'sqlite://db/video.sqlite:data_actors',autocommit=True)
            self.ds_company=dblite.open(CompanyItem,'sqlite://db/video.sqlite:data_company',autocommit=True)
            self.ds_series=dblite.open(SeriesItem,'sqlite://db/video.sqlite:data_series',autocommit=True)
            self.ds_level=dblite.open(LevelItem,'sqlite://db/video.sqlite:data_levels',autocommit=True)
            self.ds_genres=dblite.open(GenreItem,'sqlite://db/video.sqlite:data_genres',autocommit=True)

        except Exception as ex:
            print("--------------------------------")
            print(str(ex))
            print("--------------------------------")
Example #9
0
 def open_spider(self, spider):
     self.ds = dblite.open(SexoffScraperItem, 'sqlite://data.sqlite:data', autocommit=True)
Example #10
0
 def open_spider(self, spider):
     # self.ds = dblite.open(YPSqliteItem, 'sqlite://YellowPageSSsUS.db:YP_2', autocommit=True)
     self.ds = dblite.open(YPItem, "sqlite://YP.db:YP_2", autocommit=True)
Example #11
0
 def open_spider(self, spider):
     super(CoverFilePipeline, self).open_spider(spider)
     self.covers = dblite.open(CoverPicture, 'sqlite://./db.sqlite3:covers', autocommit=True)
Example #12
0
 def open_spider(self, spider):
     self.videos = dblite.open(Video, 'sqlite://./db.sqlite3:videos', autocommit=True)
     self.artists = dblite.open(Artist, 'sqlite://./db.sqlite3:artists', autocommit=True)
     self.companies = dblite.open(Company, 'sqlite://./db.sqlite3:companies', autocommit=True)
     self.genres = dblite.open(Genre, 'sqlite://./db.sqlite3:genres', autocommit=True)
Example #13
0
 def open_spider(self, spider):
     self.ds = dblite.open(SexoffScraperItem,
                           'sqlite://data.sqlite:data',
                           autocommit=True)