久久福利_99r_国产日韩在线视频_直接看av的网站_中文欧美日韩_久久一

您的位置:首頁技術(shù)文章
文章詳情頁

python-mysql Commands out of sync

瀏覽:148日期:2022-09-04 17:15:24

問題描述

python 執(zhí)行mysql 出現(xiàn)Commands out of sync; you can’t run this command now請(qǐng)問怎么解決啊錯(cuò)誤提示:Exception mysql_exceptions.ProgrammingError: (2014, 'Commands out of sync; you can’t run this command now') in <bound method DictCursor.__del_ of <MySQLdb.cursors.DictCursor object at 0x7f5ebc265050>> ignored

import jsonimport reimport tracebackimport binasciiimport time

from django.db import modelsimport MySQLdb as mdbimport MySQLdb.cursors

search_conn = mdb.connect(’127.0.0.1’, ’**’, ’’, ’’, port=9306, charset=’utf8’, cursorclass=MySQLdb.cursors.DictCursor)search_conn.ping(True)re_punctuations = re.compile(

ur'。|,|,|!|…|!|《|》|<|>|'|’|:|:|?|?|、|||“|”|‘|’|;||—|_|=|(|)|·|(|)| |.|【|】|『|』|@|&|%|^|*|+|||<|>|~|`|[|]')

def get_conn():

return mdb.connect(’127.0.0.1’, ’***’, ’’, ’’, port=9306, charset=’utf8’, cursorclass=MySQLdb.cursors.DictCursor)

def escape_string(string):

return re.sub(r'([’`=()|-!@~'&/^$])', r'1', string)

def split_words(string):

string = re_punctuations.sub(u’ ’, string).replace(u’-’, u’ ’)words = []for w in string.split(): try:words.append(w.encode(’ascii’).decode(’ascii’)) except:for c in w: words.append(c)return u’|’.join(words).strip(u’|’)

class HashManager(models.Manager):

def search(self, keyword, start=0, count=10, category=None, sort=None): search_cursor = search_conn.cursor() sql = ’’’SELECT id FROM rt_main’’’ conds = [] values = [] if keyword:conds.append(’MATCH(%s)’)values.append(escape_string(keyword)) if category:conds.append(’category=%s’)values.append(binascii.crc32(category)&0xFFFFFFFFL) if conds:sql += ’ WHERE ’ + ’ AND ’.join(conds) if sort == ’create_time’:sql += ’ ORDER BY create_time DESC ’ elif sort == ’length’:sql += ’ ORDER BY length DESC ’ sql += ’’’LIMIT %s,%sOPTION max_matches=1000, max_query_time=200 ’’’ search_cursor.execute(sql, values + [start, count]) items = list(search_cursor.fetchall()) search_cursor.execute(’SHOW META’) meta = {} for d in search_cursor.fetchall():meta[d[’Variable_name’]] = d[’Value’] sql = ’’’SELECT category, COUNT(*) AS num FROM rt_main ’’’ if conds:sql += ’ WHERE ’ + ’ AND ’.join(conds) sql += ’’’ GROUP BY category OPTION max_query_time=200’’’ search_cursor.execute(sql, values) cats = list(search_cursor.fetchall())res = {’result’: { ’items’: items, ’meta’: meta,},’cats’: { ’items’: cats,}, } search_cursor.close() return resdef list_with_files(self, ids): res = [] if len(ids[0]) == 40:items = Hash.objects.filter(info_hash__in=ids).values() else:items = Hash.objects.filter(id__in=ids).values() res = list(items) items = FileList.objects.filter(info_hash__in=[x[’info_hash’] for x in res]).values() for x in res:for y in items: if x[’info_hash’] == y[’info_hash’]:try: x[’files’] = json.loads(y[’file_list’])except ValueError: pass items = Extra.objects.filter(hash_id__in=ids).values() for x in res:for y in items: if x[’id’] == y[’hash_id’]:x[’extra’] = y return resdef list_related(self, hash_id, name, count=10): string = split_words(name) if not string:return [] search_conn = get_conn() search_cursor = search_conn.cursor() try:sql = ’’’SELECT id FROM rt_main WHERE MATCH(%s) AND id<>%s LIMIT 0,%s OPTION max_matches=1000, max_query_time=200’’’search_cursor.execute(sql, (string, hash_id, count))ids = [x[’id’] for x in search_cursor.fetchall()]items = Hash.objects.only(’name’, ’length’, ’create_time’, ’id’).filter(id__in=ids).values() except:traceback.print_exc()items = [] search_cursor.close() search_conn.close() return items

問題解答

回答1:

這個(gè)是Mysql報(bào)的錯(cuò),你分析一下自己的sql語句,看有沒有什么問題

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 国产成人片| 97久久精品午夜一区二区 | 亚洲精品字幕 | 久久精品成人一区二区三区蜜臀 | 青青草久久 | 久久久久国产 | 成人欧美日韩一区二区三区 | 精品一区二区免费视频 | 欧美激情在线精品一区二区三区 | 三级av网站 | 免费看一区二区三区 | 国产性色av | 成人一级片 | 在线视频中文字幕 | 日韩在线一区二区 | 国产精品第一区第27页 | 精品国产1区2区3区 在线国产视频 | 在线久 | 亚洲毛片在线观看 | 日日操天天操 | 精品久久久久久国产 | 精品视频在线观看 | 精品久久久av | 一区二区三区免费在线 | 欧美日韩综合视频 | 国产高清不卡在线 | 亚洲a网 | 亚洲综合区 | 欧美日韩国产精品一区 | 在线一区二区三区 | 久草久草久草 | 欧美国产日韩一区 | 欧美日韩国产一区二区三区 | 丝袜+亚洲+另类+欧美+变态 | 91中文字幕在线 | 欧美第一页 | 亚洲中出| 在线免费观看色视频 | 在线欧美 | 新91在线视频 | 狠狠久久综合 |