#NEWLINE# @ classmethod #NEWLINE# def db_worker( cls , manager ) : #NEWLINE# #INDENT# b = cls ( manager ) #NEWLINE# settings = manager . settings #NEWLINE# drop = settings . get ( 'SQLALCHEMYBACKEND_DROP_ALL_TABLES' ) #NEWLINE# clear_content = settings . get ( 'SQLALCHEMYBACKEND_CLEAR_CONTENT' ) #NEWLINE# metadata_m = b . models [ 'MetadataModel' ] #NEWLINE# queue_m = b . models [ 'QueueModel' ] #NEWLINE# if drop : #NEWLINE# #INDENT# metadata_m . __table__ . drop ( bind = b . engine ) #NEWLINE# queue_m . __table__ . drop ( bind = b . engine ) #NEWLINE# #UNINDENT# metadata_m . __table__ . create ( bind = b . engine ) #NEWLINE# queue_m . __table__ . create ( bind = b . engine ) #NEWLINE# if clear_content : #NEWLINE# #INDENT# session = b . session_cls ( ) #NEWLINE# session . execute ( metadata_m . __table__ . delete ( ) ) #NEWLINE# session . execute ( queue_m . __table__ . delete ( ) ) #NEWLINE# session . close ( ) #NEWLINE# #UNINDENT# b . _metadata = Metadata ( b . session_cls , metadata_m , settings . get ( 'SQLALCHEMYBACKEND_CACHE_SIZE' ) ) #NEWLINE# b . _queue = Queue ( b . session_cls , queue_m , settings . get ( 'SPIDER_FEED_PARTITIONS' ) ) #NEWLINE# return b