示例#1
0
文件: models.py 项目: k3an3/movies
def db_init():
    db.connect()
    try:
        db.create_tables([Movie])
        print('Creating tables...')
    except OperationalError:
        pass
    db.close()
示例#2
0
文件: scrape.py 项目: julians/zcraper
def scrape():
    r = requests.get(DOWNLOAD_URL)
    soup = BeautifulSoup(r.text, "html.parser")

    teaser = soup.select(".main article")

    if len(teaser):
        teaser = teaser[0]
    else:
        return

    unique_id = teaser["data-unique-id"].strip().replace("https", "http")

    db.connect()
    db.create_tables([Image, Author, Aufmacher, TweetJob], safe=True)

    possible_duplicate = Aufmacher.select().where(Aufmacher.unique_id == unique_id)
    if not len(possible_duplicate):
        get_article_data(unique_id)

    db.close()
示例#3
0
'''
# using proxy in Russia
apihelper.proxy = {
    # 'http': 'http://46.101.149.132:3128',
    # 'https': 'https://46.101.149.132:3128'
    # 'http': 'http://79.138.99.254:8080',
    # 'https': 'https://79.138.99.254:8080'
     'http': 'http://5.148.128.44:80',
     'https': 'https://5.148.128.44:80'
    # 'http': 'http://167.99.242.198:8080',
    # 'https': 'https://167.99.242.198:8080'
}
'''
# create tables in db
db.connect()
db.create_tables([User, Player, Challenge])

# create GOD if not exists
try:
    god = User.get(User.tg_id == config.creatorID)
except DoesNotExist:
    god = User.create(tg_id=config.creatorID, username=config.creatorUsername, name='Yury', role=Role.GOD)


@MWT(timeout=5*60)
def get_privilege_ids(role):
    logger.info("Update list of %s", role)
    return [user.tg_id for user in User.select().where(User.role >= role)]


def restricted(role):
示例#4
0
'''
# using proxy in Russia
apihelper.proxy = {
    # 'http': 'http://46.101.149.132:3128',
    # 'https': 'https://46.101.149.132:3128'
    # 'http': 'http://79.138.99.254:8080',
    # 'https': 'https://79.138.99.254:8080'
     'http': 'http://5.148.128.44:80',
     'https': 'https://5.148.128.44:80'
    # 'http': 'http://167.99.242.198:8080',
    # 'https': 'https://167.99.242.198:8080'
}
'''
# create tables in db
db.connect()
db.create_tables([User, Groups])

# create GOD if not exists
try:
    god = User.get(User.tg_id == config.creatorID)
except DoesNotExist:
    god = User.create(tg_id=config.creatorID,
                      username=config.creatorUsername,
                      name='Yury',
                      role=Role.GOD)

# create groups if not exists
_groups = Groups.select()
if len(_groups) == 0:
    for group_no in config.group_numbers:
        Groups.create(group_no=group_no)
def create_db_tables():
    db.create_tables([Brand, SubBrand, Range, Model, Guitar])
示例#6
0
 def populate_db(self, path):
     if not Track.table_exists():
         db.create_tables([Track])
     db.connect()
     self.recursive_walk(path)