backend.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:smtk 作者: Data4Democracy 项目源码 文件源码
def setup_sqlite(db_url, collection):
    """
    create required tables & indexes
    """
    if collection == 'twitter':
        db = dataset.connect(db_url)

        connections = db['connection']
        users = db['user']
        tweets = db['tweet']
        medias = db['media']
        mentions = db['mention']
        urls = db['url']
        hashtags = db['hashtag']

        tweets.create_index(['tweet_id'])
        medias.create_index(['tweet_id'])
        mentions.create_index(['user_id'])
        mentions.create_index(['mentioned_user_id'])
        urls.create_index(['tweet_id'])
        hashtags.create_index(['tweet_id'])
        users.create_index(['user_id'])
        connections.create_index(['friend_id'])
        connections.create_index(['follower_id'])

    return db
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号