Пример #1
0
 def create_chapter_table(self):
     sql = '''
         CREATE TABLE if not exists `chapter` (
           `chapter_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
           `chapter_name` varchar(255) NOT NULL,
           `chapter_url` varchar(255) NOT NULL,
           `content` TEXT NOT NULL,
           `previous_chapter_url` varchar(255) DEFAULT NULL,
           `next_chapter_url` varchar(2048) DEFAULT NULL,
           `novel_id` bigint(20) NOT NULL,
           `create_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
           `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
           PRIMARY KEY (`chapter_id`),
           UNIQUE KEY `c_id` (`chapter_id`)
         ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
     '''
     DATABASE_OBJECT.query(sql)
Пример #2
0
 def check_chapter_exist(self, chapter_url):
     url_obj = URLFilter(chapter_url)
     check_chapter_url = url_obj.get_novel_url() + url_obj.get_url_end()
     results = DATABASE_OBJECT.query(
         '''select * from chapter where chapter_url = '%s';''' %
         check_chapter_url)
     if len(results) == 0:
         return False
     return True
Пример #3
0
 def get_chapter_id(self, url):
     url_obj = URLFilter(url)
     check_chapter_url = url_obj.get_novel_url() + url_obj.get_url_end()
     results = DATABASE_OBJECT.query(
         '''select * from chapter where chapter_url = '%s';''' %
         check_chapter_url)
     if len(results) == 0:
         return
     for result in results:
         return result.chapter_id
Пример #4
0
 def check_novel_exist(self, novel_url):
     url_obj = URLFilter(novel_url)
     check_novel_url = url_obj.get_novel_url()
     from CONSTANTS import DATABASE_OBJECT
     results = DATABASE_OBJECT.query(
         '''select * from novel where novel_url = '%s';''' %
         check_novel_url)
     if len(results) == 0:
         return False
     return True
Пример #5
0
 def get_novel_id(self, url):
     url_obj = URLFilter(url)
     check_novel_url = url_obj.get_novel_url()
     from CONSTANTS import *
     results = DATABASE_OBJECT.query(
         '''select * from novel where novel_url = '%s';''' %
         check_novel_url)
     if len(results) == 0:
         return
     for result in results:
         return result.novel_id