本文整理汇总了Python中database.db.CommandQueue.put方法的典型用法代码示例。如果您正苦于以下问题:Python CommandQueue.put方法的具体用法?Python CommandQueue.put怎么用?Python CommandQueue.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database.db.CommandQueue
的用法示例。
在下文中一共展示了CommandQueue.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_gallery_hash
# 需要导入模块: from database.db import CommandQueue [as 别名]
# 或者: from database.db.CommandQueue import put [as 别名]
def get_gallery_hash(gallery_id, chapter, page=None):
"""
returns hash of chapter. If page is specified, returns hash of chapter page
"""
assert isinstance(gallery_id, int)
assert isinstance(chapter, int)
if page:
assert isinstance(page, int)
chap_id = ChapterDB.get_chapter_id(gallery_id, chapter)
if not chap_id:
return None
exceuting = []
if page:
exceuting.append(["SELECT hash FROM hashes WHERE series_id=? AND chapter_id=? AND page=?",
(gallery_id, chap_id, page)])
else:
exceuting.append(["SELECT hash FROM hashes WHERE series_id=? AND chapter_id=?",
(gallery_id, chap_id)])
hashes = []
CommandQueue.put(exceuting)
c = ResultQueue.get()
for h in c.fetchall():
try:
hashes.append(h['hash'])
except KeyError:
pass
return hashes
示例2: del_all_chapters
# 需要导入模块: from database.db import CommandQueue [as 别名]
# 或者: from database.db.CommandQueue import put [as 别名]
def del_all_chapters(series_id):
"Deletes all chapters with the given series_id"
assert isinstance(series_id, int), "Please provide a valid gallery ID"
executing = [["DELETE FROM chapters WHERE series_id=?", (series_id,)]]
CommandQueue.put(executing)
c = ResultQueue.get()
del c
示例3: get_all_gallery
# 需要导入模块: from database.db import CommandQueue [as 别名]
# 或者: from database.db.CommandQueue import put [as 别名]
def get_all_gallery():
"""Careful, might crash with very large libraries i think...
Returns a list of all galleries (<Gallery> class) currently in DB"""
executing = [["SELECT * FROM series"]]
CommandQueue.put(executing)
cursor = ResultQueue.get()
all_gallery = cursor.fetchall()
return GalleryDB.gen_galleries(all_gallery)
示例4: get_all_tags
# 需要导入模块: from database.db import CommandQueue [as 别名]
# 或者: from database.db.CommandQueue import put [as 别名]
def get_all_tags():
"""
Returns all tags in database in a list
"""
executing = [['SELECT tag FROM tags']]
CommandQueue.put(executing)
cursor = ResultQueue.get()
tags = [t['tag'] for t in cursor.fetchall()]
return tags
示例5: get_all_ns
# 需要导入模块: from database.db import CommandQueue [as 别名]
# 或者: from database.db.CommandQueue import put [as 别名]
def get_all_ns():
"""
Returns all namespaces in database in a list
"""
executing = [['SELECT namespace FROM namespaces']]
CommandQueue.put(executing)
cursor = ResultQueue.get()
ns = [n['namespace'] for n in cursor.fetchall()]
return ns
示例6: del_chapter
# 需要导入模块: from database.db import CommandQueue [as 别名]
# 或者: from database.db.CommandQueue import put [as 别名]
def del_chapter(series_id, chap_number):
"Deletes chapter with the given number from gallery"
assert isinstance(series_id, int), "Please provide a valid gallery ID"
assert isinstance(chap_number, int), "Please provide a valid chapter number"
executing = [["DELETE FROM chapters WHERE series_id=? AND chapter_number=?",
(series_id, chap_number,)]]
CommandQueue.put(executing)
c = ResultQueue.get()
del c
示例7: update_count
# 需要导入模块: from database.db import CommandQueue [as 别名]
# 或者: from database.db.CommandQueue import put [as 别名]
def update_count(self):
if not self._fetching:
self._fetching = True
CommandQueue.put([["SELECT count(*) AS 'size' FROM series"]])
cursor = ResultQueue.get()
oldc = self.count
self.count = cursor.fetchone()['size']
if oldc != self.count:
self.COUNT_CHANGE.emit()
self._fetching = False
示例8: get_gallery_by_artist
# 需要导入模块: from database.db import CommandQueue [as 别名]
# 或者: from database.db.CommandQueue import put [as 别名]
def get_gallery_by_artist(artist):
"Returns gallery with given artist"
assert isinstance(artist, str), "Provided artist is invalid"
executing = [["SELECT * FROM series WHERE artist=?", (artist,)]]
CommandQueue.put(executing)
cursor = ResultQueue.get()
row = cursor.fetchone() # TODO: an artist can have multiple galleries :^)
gallery = Gallery()
gallery.id = row['series_id']
gallery = gallery_map(row, gallery)
return gallery
示例9: get_gallery_by_title
# 需要导入模块: from database.db import CommandQueue [as 别名]
# 或者: from database.db.CommandQueue import put [as 别名]
def get_gallery_by_title(title):
"Returns gallery with given title"
assert isinstance(id, int), "Provided title is invalid"
executing = [["SELECT * FROM series WHERE title=?", (title,)]]
CommandQueue.put(executing)
cursor = ResultQueue.get()
row = cursor.fetchone()
gallery = Gallery()
gallery.id = row['series_id']
gallery = gallery_map(row, gallery)
return gallery
示例10: look_exist_tag_map
# 需要导入模块: from database.db import CommandQueue [as 别名]
# 或者: from database.db.CommandQueue import put [as 别名]
def look_exist_tag_map(tag_id):
"Checks DB if the tag_id already exists with the namespace_id, returns id else None"
executing = [["""SELECT tags_mappings_id FROM tags_mappings
WHERE namespace_id=? AND tag_id=?""", (namespace_id, tag_id,)]]
CommandQueue.put(executing)
c = ResultQueue.get()
try: # exists
return c.fetchone()['tags_mappings_id']
except TypeError: # doesnt exist
return None
except IndexError:
return None
示例11: get_gallery_by_path
# 需要导入模块: from database.db import CommandQueue [as 别名]
# 或者: from database.db.CommandQueue import put [as 别名]
def get_gallery_by_path(path):
"Returns gallery with given path"
assert isinstance(path, str), "Provided path should be a str"
executing = [["SELECT * FROM series where series_path=?", (str.encode(path),)]]
CommandQueue.put(executing)
cursor = ResultQueue.get()
row = cursor.fetchone()
if row:
gallery = Gallery()
gallery.id = row['series_id']
gallery = gallery_map(row, gallery)
return gallery
示例12: get_records
# 需要导入模块: from database.db import CommandQueue [as 别名]
# 或者: from database.db.CommandQueue import put [as 别名]
def get_records():
self._fetching = True
remaining = self.count - len(self._current_data)
rec_to_fetch = min(remaining, self._fetch_count)
CommandQueue.put([["SELECT * FROM series LIMIT {}, {}".format(
self._offset, rec_to_fetch)]])
self._offset += rec_to_fetch
c = ResultQueue.get()
new_data = c.fetchall()
gallery_list = add_method_queue(GalleryDB.gen_galleries, False, new_data)
#self._current_data.extend(gallery_list)
self.GALLERY_EMITTER.emit(gallery_list)
self._fetching = False
示例13: look_exists
# 需要导入模块: from database.db import CommandQueue [as 别名]
# 或者: from database.db.CommandQueue import put [as 别名]
def look_exists(hash):
"""check if hash already exists in database
returns hash, else returns None"""
executing = [["SELECT hash FROM hashes WHERE hash = ?",
(hash,)]]
CommandQueue.put(executing)
c = ResultQueue.get()
try: # exists
return c.fetchone()['hash']
except TypeError: # doesnt exist
return None
except IndexError:
return None
示例14: get_gallery_by_fav
# 需要导入模块: from database.db import CommandQueue [as 别名]
# 或者: from database.db.CommandQueue import put [as 别名]
def get_gallery_by_fav():
"Returns a list of all gallery with fav set to true (1)"
x = 1
executing = [["SELECT * FROM series WHERE fav=?", (x,)]]
CommandQueue.put(executing)
cursor = ResultQueue.get()
gallery_list = []
for row in cursor.fetchall():
gallery = Gallery()
gallery.id = row["series_id"]
gallery = gallery_map(row, gallery)
gallery_list.append(gallery)
return gallery_list
示例15: get_gallery_by_id
# 需要导入模块: from database.db import CommandQueue [as 别名]
# 或者: from database.db.CommandQueue import put [as 别名]
def get_gallery_by_id(id):
"Returns gallery with given id"
assert isinstance(id, int), "Provided ID is invalid"
executing = [["SELECT * FROM series WHERE series_id=?", (id,)]]
CommandQueue.put(executing)
cursor = ResultQueue.get()
row = cursor.fetchone()
gallery = Gallery()
try:
gallery.id = row['series_id']
gallery = gallery_map(row, gallery)
return gallery
except TypeError:
return None