def save(download_media): # type: (DownloadMedia) -> long logging.debug('save download_media: %s', download_media.download_url) sql_client = ConfigInit().get_conn() sql_check = 'select id from download_media where hash_sign="%s"' % download_media.hash_sign result = sql_client.getOne(sql_check) if result: download_media.id = result['id'] update(download_media) else: download_media.id = insert(download_media) return download_media.id
def demo_mysql(): conn = ConfigInit().get_conn() aa = conn.getOne('select count(*) from download_media') pass
def select_by_hash_sign(hash_sign): # type: (str) -> long sql = 'select id from download_media where hash_sign="%s" and download_status=1' % hash_sign client = ConfigInit().get_conn() return client.getOne(sql)