本文整理汇总了Python中db.Db.fetchone方法的典型用法代码示例。如果您正苦于以下问题:Python Db.fetchone方法的具体用法?Python Db.fetchone怎么用?Python Db.fetchone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.Db
的用法示例。
在下文中一共展示了Db.fetchone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_other_users
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import fetchone [as 别名]
def generate_other_users( self, limit=10 ):
users = self.chomik.generate_list( limit, to_file=False )
for user in users if users else []:
self.chomik.sleep( self.server.timeout )
self.chomik.invite( user )
if not Db.fetchone( "SELECT * FROM other_users WHERE login=?", ( user, ) ):
Db.execute( "INSERT INTO other_users ( login ) VALUES ( ? )", ( user, ), commit=True )
示例2: run
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import fetchone [as 别名]
def run( self ):
try:
if self.strategy == 'film_db': #TODO
self.chomik.connect()
movies = []
file = open( 'db/movies.list', 'r' )
for line in file.readlines():
title = line.split('\t')[0].decode( 'latin1' )
analized = analyze_title( title )
title = analized['title']
if analized['kind'] in ( 'movie', 'tv series', 'tv movie', 'tv mini series', 'episode' ):
movies.append( analized )
file.close()
random.shuffle( movies )
for movie in movies:
title = movie['title'].replace( '/', '\\')
year = movie['year'] if movie.has_key( 'year' ) else ''
FIRST_LETTER = title[0].upper()
if movie['kind'] == 'episode':
pattern1 = [
'Seriale',
'Alfabetycznie',
movie['episode of']['title'][0].upper(),
movie['episode of']['title'] + ' (%s)' % movie['episode of']['year'] if movie['episode of'].has_key( 'year' ) else '',
]
if movie.has_key( 'season' ):
pattern1.append( 'Sezon %s' % movie['season'] )
if movie.has_key( 'episode' ):
pattern1.append( 'Odcinek %s, %s' % ( movie['episode'], movie['title'] ) )
else:
pattern1.append( title )
pattern1 = '/'.join( pattern1 )
patterns = [ pattern1 ]
if movie['episode of'].has_key( 'year' ):
pattern2 = [
'Seriale',
'Chronologicznie',
str( movie['episode of']['year'] ),
movie['episode of']['title'] + ' (%s)' % movie['episode of']['year'] if movie['episode of'].has_key( 'year' ) else '',
]
if movie.has_key( 'season' ):
pattern2.append( 'Sezon %s' % movie['season'] )
if movie.has_key( 'episode' ):
pattern2.append( 'Odcinek %s, %s' % ( movie['episode'], movie['title'] ) )
else:
pattern2.append( title )
pattern2 = '/'.join( pattern2 )
patterns.append( pattern2 )
else:
title = '%s (%s)' % ( title, year ) if year else title
if movie['kind'] in ( 'tv series', 'tv mini series' ):
folder = 'Seriale'
else:
folder = 'Filmy'
full_title = ( "%s (%s)" % ( movie['title'], year ) ).decode( 'latin1' )
patterns = ( '%s/Alfabetycznie/%s/%s' % ( folder, FIRST_LETTER, title ),
'%s/Chronologicznie/%s/%s' % ( folder, year, title )
)
if not Db.fetchone( "SELECT * FROM folders WHERE user_id=? AND name=?", ( self.id, title ) ):
good = []
if movie['kind'] in ( 'movie', 'tv movie' ): # TODO search series
sizes = []
self.chomik.logger.debug( 'searching: %s' % full_title )
items = self.chomik.search( full_title )
self.chomik.logger.debug( 'find: %d' % len( items ) )
for item in items:
self.chomik.logger.debug( '%s, %s' % item['title'], item['size'] )
if item['title'].lower() == full_title.lower() or item['title'].lower().startswith( full_title.lower() ) or item['title'].lower() == movie['title'].lower() or item['title'].lower == ( '%s %s' % ( movie['title'], year ) ).lower():
if not item['size'] in sizes:
good.append( item )
sizes.append( item['size'] )
for pattern in patterns:
id, url = self.chomik.create_directory( pattern )
if id and url:
Db.execute( "INSERT INTO folders VALUES (?, ?, ?, ?)", ( id, self.id, title, url ), commit=True )
for item in good:
self.chomik.clone( item['id'], id )
elif self.strategy == 'smieciarz':
if self.chomik.connect():
self.generate_other_users()
users = Db.fetch( "SELECT login from other_users" )
random.shuffle( users )
for user in users:
url = '/%s' % user
#.........这里部分代码省略.........