本文整理匯總了Python中db.DB.escapeString方法的典型用法代碼示例。如果您正苦於以下問題:Python DB.escapeString方法的具體用法?Python DB.escapeString怎麽用?Python DB.escapeString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類db.DB
的用法示例。
在下文中一共展示了DB.escapeString方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: search
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import escapeString [as 別名]
def search(self, search, limit=1000, excludedcats={}):
mdb = DB()
# if the query starts with a ^ it indicates the search is looking for items which start with the term
# still do the like match, but mandate that all items returned must start with the provided word
words = search.split(' ')
searchsql = ''
intwordcount = 0
if len(words) > 0:
for word in words:
# see if the first word has a caret, which indicates search must start with term
if intwordcount == 0 and word[0] == '^':
searchsql += ' and b.name like %s%' % (mdb.escapeString(word[1:]))
else:
searchsql += ' and b.name like %s' % (mdb.escapeString('%'+word+'%'))
intwordcount += 1
exccatlist = ''
if len(excludedcats) > 0:
exccatlist = 'and b.categoryID not in ('+','.join(excludedcats)+') '
res = mdb.query('''SELECT b.*, g.name AS group_name, r.guid,
(SELECT COUNT(ID) FROM parts p where p.binaryID = b.ID) as 'binnum'
FROM binaries b
INNER JOIN groups g ON g.ID = b.groupID
LEFT OUTER JOIN releases r ON r.ID = b.releaseID
WHERE 1=1 %s %s order by DATE DESC LIMIT %d ''', (searchsql, exccatlist, limit))
return res
示例2: getCountInactive
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import escapeString [as 別名]
def getCountInactive(gropuname=''):
mdb = DB()
grpsql = ''
if groupname != '':
grpsql += "and groups.name like %s " % mdb.escapeString("%"+groupname+"%")
res = mdb.queryOneRow('SELECT count(ID) as num from groups where 1=1 %s and active = 0', (grpsql,))
return res['num']
示例3: addBlacklist
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import escapeString [as 別名]
def addBlacklist(self, regex):
mdb = DB()
groupname = regex['groupname']
if groupname == '':
groupname = 'null'
else:
groupname = re.sub('a\.b\.' 'alt.binaries.', groupname, re.IGNORECASE)
groupname = mdb.escapeString(groupname)
return mdb.queryInsert("insert into binaryblacklist (groupname, regex, status, description, optype, msgcol) values (%s, %s, %d, %s, %d, %d) ",
(regex['regex'], regex['status'], regex['description'], regex['optype'], regex['msgcol']))
示例4: updateBlacklist
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import escapeString [as 別名]
def updateBlacklist(self, regex):
mdb = DB()
groupname = regex['groupname']
if groupname == '':
groupname = 'null'
else:
groupname = re.sub('a\.b\.' 'alt.binaries.', groupname, re.IGNORECASE)
groupname = mdb.escapeString(groupname)
mdb.query("update binaryblacklist set groupname=%s, regex=%s, status=%d, description=%s, optype=%d, msgcol=%d where ID = %d ",
(groupname, regex['regex'], regex['description'], regex['optype'], regex['msgcol'], regex['id']))
示例5: disableForPost
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import escapeString [as 別名]
def disableForPost(name):
mdb = DB()
mdb.queryOneRow("update groups set first_record_postdate = %s where name = %s", ('2000-00-00 00:00:00', mdb.escapeString(name)))