当前位置: 首页>>代码示例>>Python>>正文


Python Db.execute方法代码示例

本文整理汇总了Python中db.Db.execute方法的典型用法代码示例。如果您正苦于以下问题:Python Db.execute方法的具体用法?Python Db.execute怎么用?Python Db.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在db.Db的用法示例。


在下文中一共展示了Db.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import execute [as 别名]
 def execute( self ):
     self.server.timeout = int( self.timeout )
     if not Db.fetch( "SELECT * FROM settings WHERE key='timeout'" ):
         Db.execute( "INSERT INTO settings VALUES ('timeout', ?, 'INT' ) ", ( self.timeout, ), commit=True )
     else:
         Db.execute( "UPDATE settings SET value=? WHERE key='timeout'", ( self.timeout, ), commit=True )
     print self.DONE
开发者ID:jackMort,项目名称:hamster-bot,代码行数:9,代码来源:server.py

示例2: generate_other_users

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import execute [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 )
开发者ID:jackMort,项目名称:hamster-bot,代码行数:11,代码来源:server.py

示例3: suppr_utilisateurs

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import execute [as 别名]
def suppr_utilisateurs(id) :
    db=Db()

    result = db.execute('DELETE FROM utilisateurs WHERE id = %(id)s', {
    'id' : id
    })
    db.close()

    resp = make_response(json.dumps(result),200)
    resp.mimetype='application/json'
    return resp
开发者ID:imerir-web1A-201516,项目名称:tp6-aguarro,代码行数:13,代码来源:main.py

示例4: pret_update

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import execute [as 别名]
def pret_update(pret_id):
    data = request.get_json()

    db = Db()
    pret = db.select("SELECT * FROM prets WHERE prets.pret_id = %(pret_id)s", {
        'pret_id': pret_id
    })

    if len(pret) != 1:
        db.close()
        resp = make_response(json.dumps({'error': 'Given pret_id not found in database.'}), 404)
        resp.mimetype = 'application/json'
        return resp

    pret = pret[0]

    try:
        pret['pret_quoi'] = data['pret_quoi']
    except KeyError:
        pass

    try:
        pret['pret_qui'] = data['pret_qui']
    except KeyError:
        pass

    try:
        pret['pret_etat'] = data['pret_etat']
    except KeyError:
        pass

    db.execute('UPDATE prets SET pret_quoi = %(pret_quoi)s, pret_qui = %(pret_qui)s, pret_etat = %(pret_etat)s WHERE prets.pret_id = %(pret_id)s', {
       'pret_quoi': pret['pret_quoi'],
       'pret_qui': pret['pret_qui'],
       'pret_etat': pret['pret_etat'],
       'pret_id': pret['pret_id'],
    })
    db.close()

    return make_response('', 204)
开发者ID:imerir-web1A-201516,项目名称:tp6-LimNicolas,代码行数:42,代码来源:main.py

示例5: prets_add

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import execute [as 别名]
def prets_add():
  data = request.get_json()

  if (data["statut"] == "prete") or (data["statut"] == "rendu") or (data["statut"] == "annule"):
    db = Db()
    db.execute("INSERT INTO prets (quoi, qui, statut) VALUES (%(quoi)s, %(qui)s, %(statut)s)", {
      'quoi': data["quoi"],
      'qui': data["qui"],
      'statut': data["statut"]
    })
	
    last_id =  db.lastrowid()

    db.close()
  
    resp = make_response("OK", 200)
    #resp.headers['Location'] = '/prets/%d' % last_id
    resp.mimetype = 'application/json'
  else:
    resp = make_response("Le prêt n'a pas pu être créé.", 400)

  return resp
开发者ID:imerir-web1A-201516,项目名称:tp6-milanteles,代码行数:24,代码来源:main.py

示例6: suppr_prets

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import execute [as 别名]
def suppr_prets(id):
    db = Db()

    result = db.execute("DELETE FROM prets WHERE id = %(id)s",{
    'id':id,
    })
    db.close()



    resp = make_response(json.dumps(result),204)
    resp.mimetype = 'application/json'
    return resp
开发者ID:imerir-web1A-201516,项目名称:tp6-aguarro,代码行数:15,代码来源:main.py

示例7: modif_utilisateurs

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import execute [as 别名]
def modif_utilisateurs(id):
    data = request.get_json ()
    db = Db()

    result = db.execute("UPDATE utilisateurs SET nom = %(nom)s, prenom = %(prenom)s WHERE id = %(id)s",{
    'id':id,
    'nom':data["nom"],
    'prenom':data["prenom"]
    })
    db.close()



    resp = make_response(json.dumps(result),204)
    resp.mimetype = 'application/json'
    return resp
开发者ID:imerir-web1A-201516,项目名称:tp6-aguarro,代码行数:18,代码来源:main.py

示例8: users_changeone

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import execute [as 别名]
def users_changeone(id):
  try :
    data = request.get_json()
    db = Db()
    result = db.execute("UPDATE users SET nom = %(nom)s, prenom = %(prenom)s WHERE id=%(id)s",{
      'nom' : data['nom'],
      'prenom' : data['prenom'],
      'id' : id
    })
    
    
    resp = make_response('', 204)
    db.close()
    return resp
  except:
    resp = make_response('', 400)
    return resp
开发者ID:imerir-web1A-201516,项目名称:tp6-gwenoleR,代码行数:19,代码来源:main.py

示例9: prets_changeone

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import execute [as 别名]
def prets_changeone(id):
  try :
    data = request.get_json()
    db = Db()
    result = db.execute("UPDATE prets SET qui = %(qui)s, quoi = %(quoi)s, statut = %(statut)s WHERE id=%(id)s",{
      'qui' : data['qui'],
      'quoi' : data['quoi'],
      'statut' : data['statut'],
      'id' : id
    })
    
    
    resp = make_response('', 204)
    db.close()
    return resp
  except:
    resp = make_response('', 400)
    return resp
开发者ID:imerir-web1A-201516,项目名称:tp6-gwenoleR,代码行数:20,代码来源:main.py

示例10: ajouter_utilisateurs

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import execute [as 别名]
def ajouter_utilisateurs():
    data = request.get_json ()
    try :
        db=Db()

        result = db.execute('INSERT INTO utilisateurs ("nom", "prenom") VALUES (%(nom)s,%(prenom)s)', {
        'nom' : data["nom"],
        'prenom' : data["prenom"]
        })
        db.close()

        resp = make_response(json.dumps(result))
        resp.mimetype = 'application/json'
        return resp

    except :
        resp = make_resonse('Bad Request', 400)
        return resp
开发者ID:imerir-web1A-201516,项目名称:tp6-aguarro,代码行数:20,代码来源:main.py

示例11: prets_updateone

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import execute [as 别名]
def prets_updateone(id):
  data = request.get_json()
  
  if (data["statut"] == "prete") or (data["statut"] == "rendu") or (data["statut"] == "annule"):
    db = Db()
    result = db.execute("UPDATE prets SET quoi = %(quoi)s, qui = %(qui)s, statut = %(statut)s WHERE id = %(id)s", {
      'quoi': data["quoi"],
      'qui': data["qui"],
      'statut': data["statut"],
      'id': id
    })
    db.close()

    resp = make_response("", 204)
    resp.mimetype = 'application/json'
  else:
    resp = make_response("Le prêt n'a pas pu être modifié.", 400)

  return resp
开发者ID:imerir-web1A-201516,项目名称:tp6-milanteles,代码行数:21,代码来源:main.py

示例12: modif_prets

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import execute [as 别名]
def modif_prets(id):
    data = request.get_json ()

    try :
        db = Db()

        result = db.execute("UPDATE prets SET quoi = %(quoi)s, qui = %(qui)s, status = %(status)s WHERE id = %(id)s RETURNING id",{
        'id':id,
        'quoi':data["quoi"],
        'qui':data["qui"],
        'status':data["status"]
        })
        db.close()

        resp = make_response(json.dumps(result),204)
        resp.mimetype = 'application/json'
        return resp

    except :
        resp = make_response ('NOT FOUND', 404)
        return resp
开发者ID:imerir-web1A-201516,项目名称:tp6-aguarro,代码行数:23,代码来源:main.py

示例13: Db

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import execute [as 别名]
#!/usr/local/bin/python3

import constants
from db import Db

repos = {}
granularities = ('fine_grained', 'coarse_grained')

db = Db()

cursor = db.execute("select id, arquivo from grafos")

for (id, a) in cursor:
	arr = a.split('.')
	repo = arr[0]
	if repo == 'eclipse':
		repo += '.' + arr[1]
	if repo == 'eclipse.platform':
		repo += '.' + arr[2]
	granularity = arr[len(arr)-3]
	level = arr[len(arr)-2]
	if granularity in granularities and level.startswith('graphL'):
		if not repo in repos:
			repos[repo] = {}
		if not granularity in repos[repo]:
			repos[repo][granularity] = []
		repos[repo][granularity].append({'id': id, 'level': int(level.replace('graphL',''))})

for repo in repos.values():
	for granularity in granularities:
		graphs = sorted(repo[granularity], key=lambda g : g['level'])
开发者ID:mcesar,项目名称:mpca,代码行数:33,代码来源:verifica-confinamento.py

示例14: reversed

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import execute [as 别名]
# print "Excluindo grafos"
# db.execute("delete from grafos where repositorio = %s", (repository,))

print "Incluindo grafos"
for file in files:
    if re.search('\.dot$', file):
        file_name = file.rpartition('/')[2]
        file_repository = None
        for k in reversed(sorted(constants.repository_map.keys())):
            if file_name.startswith(k):
                file_repository = constants.repository_map[k]
                break
        if repository != None and file_repository != repository:
            continue
        db.execute("delete from clusters_entidades where cluster in " + \
            "(select id from clusters where grafo in " + \
                "(select id from grafos where arquivo = %s))", (file_name,))
        db.execute("delete from clusters where grafo in " + \
            "(select id from grafos where arquivo = %s)", (file_name,))
        db.execute("delete from grafos where arquivo = %s", (file_name,))
        graph_id = db.insert('insert into grafos(repositorio, arquivo) values (%s,%s)', 
                        (file_repository,file_name))
    with open(file) as f:
        print file
        for line in f:
            match = re.search('subgraph (.+) {', line)                      
            if match:
                cluster_name = match.group(1)
                cluster_id = db.insert('insert into clusters(grafo, nome) values (%s,%s)', 
                        (graph_id, cluster_name))
            match = re.search('\"(\d+)\"\[', line)
开发者ID:mcesar,项目名称:mpca,代码行数:33,代码来源:importa_clusters.py

示例15: run

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import execute [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
#.........这里部分代码省略.........
开发者ID:jackMort,项目名称:hamster-bot,代码行数:103,代码来源:server.py


注:本文中的db.Db.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。