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


Python db.dbInitialize函数代码示例

本文整理汇总了Python中wrappers.db.dbInitialize函数的典型用法代码示例。如果您正苦于以下问题:Python dbInitialize函数的具体用法?Python dbInitialize怎么用?Python dbInitialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: main

def main():
  print 'Content-type: text/plain'
  print 
  db = dbInitialize(db="libtech")
  cur = db.cursor()
  form = cgi.FieldStorage()
  if form.has_key('CustomField'):# is not None:
    callid = form['CustomField'].value
    query="select audio from callQueue where callid=%s" % callid
  elif form.has_key('From'):
    phone=form['From'].value
    sid=form['CallSid'].value
    last10Phone=phone[-10:]
    query="select audio from callQueue where isTest=1 and sid='%s'" % sid
  else:
    query="select filename from audioLibrary where id=1579"
  with open('/tmp/y.txt', 'w') as outfile:
    outfile.write(str(form)+query)
  cur.execute(query)
  if cur.rowcount == 1:
    row=cur.fetchone()
    audioFiles=row[0]
    audioFileList=audioFiles.split(',')
    for audio in audioFileList:
      print "http://callmgr.libtech.info/open/audio/%s" % audio;
  else:
    print "http://callmgr.libtech.info/open/audio/1652_ResearchRSCDR2p18000.wav"
开发者ID:rajesh241,项目名称:libtech,代码行数:27,代码来源:basicExotel.py

示例2: main

def main():
  args = argsFetch()
  logger = loggerFetch(args.get('log_level'))
  db = dbInitialize(db=nregaDB, charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  
  if args['updateMusterStats']:
    updateMusterStats(cur,logger) 
  if args['selectRandomDistricts']:
    selectRandomDistricts(cur,logger)
  if args['updatePanchayatStats']:
    updatePanchayatStats(cur,logger)
  if args['genMusterURL']:
    genMusterURLs(cur,logger,args['musterID'])
  if args['downloadRejectedPaymentReport']:
    if args['finyear']:
      finyear=args['finyear']
    else:
      finyear='17'
    downloadRejectedPaymentReport(cur,logger,finyear)
  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
  logger.info("...END PROCESSING")     
  exit(0)
开发者ID:rajesh241,项目名称:libtech,代码行数:27,代码来源:houseKeepying.py

示例3: main

def main():
  print 'Content-type: text/plain'
  print 
  db = dbInitialize(db='libtech')
  cur = db.cursor()
  form = cgi.FieldStorage()
# phone=form['From'].value
# sid=form['CallSid'].value
# last10Phone=phone[-10:]
  digits=form['digits'].value
  digits=digits.strip('"')
  with open('/tmp/bihar1.txt', 'w') as outfile:
    outfile.write(str(form)+digits)
 # digits='12380030041412'
  fpsCode=digits[:-2]
  month=int(digits[-2:])

  audioFiles=getPDSAudioList(fpsCode,month)
  if audioFiles is not None:
    audioFileList=audioFiles.split(',')
    s=''
    for audioID in audioFileList:
      query="select filename from audioLibrary where id=%s " % str(audioID)
      cur.execute(query)
      row=cur.fetchone()
      audio=row[0]
      s+=audio
      print "http://callmgr.libtech.info/open/audio/%s" % audio;
    with open('/tmp/bihar.txt', 'w') as outfile:
      outfile.write(str(form)+s)
  else:
    audioFile="spss_try_again.wav"
    print "http://callmgr.libtech.info/open/audio/prompts/%s" % audioFile
  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
开发者ID:rajesh241,项目名称:libtech,代码行数:34,代码来源:biharPDSTest.py

示例4: main

def main():
  db = MySQLdb.connect(host=dbhost, user=dbuser, passwd=dbpasswd, charset='utf8')
  db = dbInitialize(db='libtech', charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  query="SET NAMES utf8"
  cur.execute(query)
  query="use libtech"
  cur.execute(query)
  query="select bid,completed,name from broadcasts where bid>1000 and error=0 and approved=1 and processed=1 and completed=0 order by bid DESC "
  print query
  cur.execute(query)
  results = cur.fetchall()
  for row in results:
    bid=str(row[0])
    completed=str(row[1])
    name=row[2]
    print bid+"  "+name+"  "+completed
    query="select a.district,a.block,a.panchayat,c.phone,DATE_FORMAT(c.callStartTime,'%d-%M-%Y') callTime,c.status,c.attempts,c.duration,c.durationPercentage,f.feedback,c.sid from addressbook a,callSummary c left join callFeedback f on c.sid=f.sid where c.phone=a.phone and bid="+str(bid)
    if(completed == '0' or completed=='1'):
      csvname=broadcastReportFilePath+str(bid)+"_"+name.replace(' ',"")+".csv"
      print csvname
      writecsv(cur,query,csvname)
      updateBroadcastTable(cur,bid)
    query="select bid,vendor,phone,callStartTime,duration,vendorCallStatus,cost from callLogs where bid=%s order by phone" % str(bid) 
    if(completed == '0' or completed=='1'):
      csvname=broadcastReportFilePath+str(bid)+"_"+name.replace(' ',"")+"_detailed.csv"
      print csvname
      writecsv(cur,query,csvname)
  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
  logger.info("...END PROCESSING")     
  exit(0)
开发者ID:rajesh241,项目名称:libtech,代码行数:32,代码来源:broadcastReport.py

示例5: main

def main():
  args = argsFetch()
  logger = loggerFetch(args.get('log_level'))
  logger.info('args: %s', str(args))
  db = dbInitialize(db="libtech", charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  
  query="select phone,bid from callLogs where DATE(callStartTime) = CURDATE() group by phone "
  cur.execute(query)
  results=cur.fetchall()
  for row in results:
    #rowid=str(row[0])
    phone=row[0]
    logger.info("  Phone %s " % (phone)) 
    query="select count(*) from callLogs where phone='%s'" % (phone)
    totalCalls=singleRowQuery(cur,query)
    query="select count(*) from callLogs where phone='%s' and status='pass'" % (phone)
    totalSuccessCalls=singleRowQuery(cur,query)
    if totalCalls > 0:
      logger.info("Calculating Percentage")
      successP=math.trunc(totalSuccessCalls*100/totalCalls)
    else:
      successP=0
    logger.info("Total Calls %s Success Calls %s Success Percentage %s " % (str(totalCalls),str(totalSuccessCalls),str(successP)))
    query="update addressbook set totalCalls='%s',successPercentage='%s'  where phone='%s' " % (str(totalCalls),str(successP),phone) 
    cur.execute(query)

  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
  logger.info("...END PROCESSING")     
  exit(0)
开发者ID:rajesh241,项目名称:libtech,代码行数:34,代码来源:updateCallStats.py

示例6: main

def main():
  print 'Content-type: text/html'
  print 

  form = cgi.FieldStorage()
  with open('/tmp/z.txt', 'w') as outfile:
    outfile.write(str(form))

  sid = form['CallSid'].value
  phone = form['From'].value
  digits = form['digits'].value.replace('"','')

  import os

  db = dbInitialize(db="libtech")
  cur = db.cursor()
  query="select a.filename,b.bid from broadcasts b, audioLibrary a where b.bid=%s and b.fileid=a.id" % (digits);
  cur.execute(query)
  row=cur.fetchone()
  filename=row[0]
  
  query = 'insert into testBroadcast (sid,vendor,phone,callStartTime,bid,filename) values ("%s", "exotel","%s", now(), "%s","%s")' % (sid, phone,digits,filename)
  with open('/tmp/z.txt', 'a') as outfile:
    outfile.write(query)
  cur.execute(query)
  dbFinalize(db)

  return 0
开发者ID:rajesh241,项目名称:libtech,代码行数:28,代码来源:exotelTestBroadcast.py

示例7: main

def main():
  print 'Content-type: text/html'
  print 
  myhtml=''  
  
  db = dbInitialize(db="crawlDistricts", charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  
  section_html = getButtonV2('./crawlStatus.py', 'status', 'status')
  query="select name from districts"
  hiddenNames=['districtName'] 
  hiddenValues=[0]
  query_table = "<br />"
  query_table += bsQuery2HtmlV2(cur, query, query_caption="",extraLabel='status',extra=section_html,hiddenNames=hiddenNames,hiddenValues=hiddenValues)
  myhtml+=query_table
  

  myhtml=htmlWrapper(title="NREGA Status", head='<h1 aling="center">Nrega Status</h1>', body=myhtml)
  print myhtml.encode('UTF-8')

  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
开发者ID:rajesh241,项目名称:libtech,代码行数:25,代码来源:districts.py

示例8: sql2json

def sql2json(logger,):
  db = dbInitialize(db="surguja", charset="utf8")

  query = 'select id, panchayatName, name, jobcard, musterNo, workCode, accountNo, bankNameOrPOName, musterStatus from workDetails limit 10'
  cur = db.cursor()
  cur.execute(query)
  res = fetchindict(cur)
  logger.info("Converting query[%s]" % query)
  #data = str(res[0]).encode('utf-8')
  data = res
  logger.info("Data[%s]" % data)

  '''
  with open(filename, 'wb') as outfile:
      logger.info('Writing to file[%s]' % filename)
      outfile.write(res)
  '''

  with open(filename, 'w') as outfile:
    logger.info('Writing to file[%s]' % filename)
    json.dump(data, outfile, ensure_ascii=False, indent=4)
      
  dbFinalize(db)

  return 'SUCCESS'
开发者ID:rajesh241,项目名称:libtech,代码行数:25,代码来源:mysql2json.py

示例9: main

def main():
  regex=re.compile(r'<input+.*?"\s*/>+',re.DOTALL)
  args = argsFetch()
  finyear=args['finyear']
  if args['limit']:
    limit = int(args['limit'])
  else:
    limit =50000
  if args['musterID']:
    mid=args['musterID']
  else:
    mid=None
  if args['maxProcess']:
    maxProcess=int(args['maxProcess'])
  else:
    maxProcess=1
  additionalFilters=''
  if args['district']:
    additionalFilters+= " and b.districtName='%s' " % args['district']
  if args['block']:
    additionalFilters+= " and b.blockName='%s' " % args['block']
  fullfinyear=getFullFinYear(finyear)
  logger = loggerFetch(args.get('log_level'))
  logger.info('args: %s', str(args))
  logger.info("BEGIN PROCESSING...")


  db = dbInitialize(db=nregaDB, charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  tasks = multiprocessing.JoinableQueue()
  results = multiprocessing.Queue()
  if mid is None:
    query="select m.id from musters m,blocks b where m.fullBlockCode=b.fullBlockCode and m.finyear='%s' and (m.isDownloaded=0  or (m.wdComplete=0 and TIMESTAMPDIFF(HOUR, m.downloadAttemptDate, now()) > 48 )) %s order by isDownloaded,m.downloadAttemptDate limit %s" % (finyear,additionalFilters,str(limit))
  else:
    query="select m.id from musters m where m.id=%s " % str(mid)
  logger.info(query) 
  cur.execute(query)
  noOfTasks=cur.rowcount
  results1=cur.fetchall()
  for row in results1:
    musterID=row[0]
    tasks.put(Task(musterID))  
  
  for i in range(maxProcess):
    tasks.put(None)

  myProcesses=[musterProcess(tasks, results) for i in range(maxProcess)]
  for eachProcess in myProcesses:
    eachProcess.start()
  while noOfTasks:
    result = results.get()
    logger.info(result)
    noOfTasks -= 1


  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
开发者ID:rajesh241,项目名称:libtech,代码行数:60,代码来源:downloadMusters.py

示例10: main

def main():
  args = argsFetch()
  logger = loggerFetch(args.get('log_level'))
  logger.info('args: %s', str(args))

  logger.info("BEGIN PROCESSING...")
  db = dbInitialize(db="biharPDS", charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  inyear=args['year']
  
  logger.info(inyear)
  display = displayInitialize(args['visible'])
  driver = driverInitialize(args['browser'])
  
  #Start Program here
  url="http://www.google.com"
  driver.get(url)
  myhtml=driver.page_source
  print myhtml
  # End program here

  driverFinalize(driver)
  displayFinalize(display)
  dbFinalize(db) # Make sure you put this if there are other exit paths or errors


  
  logger.info("...END PROCESSING")     
  exit(0)
开发者ID:rajesh241,项目名称:libtech,代码行数:33,代码来源:exampleSelenium.py

示例11: main

def main():
  db = dbInitialize(db="libtech")
  cur = db.cursor()
  form = cgi.FieldStorage()
  with open('/tmp/y.txt', 'w') as outfile:
    outfile.write(str(form))
 
  phone1 = form['From'].value
  phone=phone1[-10:]
  
  direction = form['Direction'].value
  isAdmin=0
  if str(direction) =='incoming': #Only for Incoming calls we need to check if the phone number is incoming or no
    #Get admin status
    query="select * from addressbook where isAdmin=1 and phone='%s' " % phone
    with open('/tmp/yyy.txt', 'w') as outfile:
      outfile.write(query)
    cur.execute(query)
    if cur.rowcount == 1:
      isAdmin=1
  if isAdmin == 1:
    print 'Status: 200 OK'
    print 
  else:
    print 'Status: 302 Found'
    print 
开发者ID:rajesh241,项目名称:libtech,代码行数:26,代码来源:exotelCheckAdmin.py

示例12: checkAudioFiles

def checkAudioFiles(logger):
  logger.info("Checking if all AudioFiles are present or not")
  db = dbInitialize(host=pdsDBHost,db=pdsDB, charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  query="select id,fpsCode from fpsShops where cRequired=1 order by id desc "
  cur.execute(query)
  results=cur.fetchall()
  for row in results:
    rowid=str(row[0])
    fpsCode=row[1]
    logger.info("row id: %s dpsCode: %s  " % (rowid,fpsCode))
    audioPresent=1
    fpsFileName="%s/fps/%s.wav" % (pdsAudioDir,fpsCode)
    if not os.path.isfile(fpsFileName):
      audioPresent=0
    logger.info("THe audioPresent : %s " % str(audioPresent))
    query="update fpsShops set audioPresent=%s where id=%s " % (str(audioPresent),rowid)
    cur.execute(query)
    query="update fpsStatus set audioPresent=%s where fpsCode=%s " % (str(audioPresent),fpsCode)
    cur.execute(query)
  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
开发者ID:rajesh241,项目名称:libtech,代码行数:25,代码来源:pdsReport.py

示例13: main

def main():
  print 'Content-type: text/html'
  print 
  myhtml=''  
  form = cgi.FieldStorage()
  additionalFilter=''
  districtName=''
  if form.has_key('district'):# is not None:
    additionalFilter+=" and b.districtName='%s' " % form["district"].value
    districtName=form["district"].value
  finyear='17'
  if form.has_key('finyear'):# is not None:
    finyear=form["finyear"].value 
  db = dbInitialize(db="nicnrega", charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  finyear='17' 
  
   
  myhtml+=  getCenterAligned('<h2 style="color:blue"> %s</h2>' % (districtName.upper()))

  myhtml+=  getCenterAligned('<h3 style="color:red"> Pending Muster Download MusterWise</h3>')
  query="select m.id,m.musterNo,b.districtName district,b.blockName block,m.wdError,TIMESTAMPDIFF(HOUR,m.downloadAttemptDate,NOW()) timeDiff,m.crawlDate,m.downloadAttemptDate from musters m,blocks b,panchayats p  where m.finyear='%s' and b.isRequired=1 and m.fullBlockCode=b.fullBlockCode and m.stateCode=p.stateCode and m.districtCode=p.districtCode and m.blockCode=p.blockCode and m.panchayatCode=p.panchayatCode and p.isRequired=1  and m.musterType='10' and (m.isDownloaded=0 or m.wdError=1 or (m.wdComplete=0 and TIMESTAMPDIFF(HOUR, m.downloadAttemptDate, now()) > 48 ) ) %s order by isDownloaded,TIMESTAMPDIFF(HOUR,m.downloadAttemptDate,NOW()) DESC limit 4" % (finyear,additionalFilter)
  query_table = "<br />"
  query_table += bsQuery2HtmlV2(cur, query, query_caption="")
  myhtml+=query_table
 
  myhtml=htmlWrapper(title="NREGA Status", head='<h1 aling="center">Nrega Status</h1>', body=myhtml)
  print myhtml.encode('UTF-8')
  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
开发者ID:rajesh241,项目名称:libtech,代码行数:33,代码来源:crawlStatus.py

示例14: __init__

 def __init__(self, task_queue, result_queue):
     multiprocessing.Process.__init__(self)
     self.task_queue = task_queue
     self.result_queue = result_queue
     self.pyConn = dbInitialize(db=nregaDB, charset="utf8")  # The rest is updated automatically in the function
     #self.pyConn.set_isolation_level(0)
     self.pyConn.autocommit(True)
开发者ID:rajesh241,项目名称:libtech,代码行数:7,代码来源:downloadMusters.py

示例15: main

def main():
  print 'Content-type: text/html'
  print 
 
  db = dbInitialize(db="biharPDS", charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  
  queryFilter=' and ' 
  distCodeValue='000'
  blockCodeValue='000'
  fpsCodeValue='000' 
  noInputPassed=1
  form = cgi.FieldStorage()
  if form.has_key('distCode'):
    noInputPassed=0
    distCodeValue=form["distCode"].value
    queryFilter+="p.distCode = '%s' and " %(distCodeValue)
    if form.has_key('blockCode'):
      blockCodeValue=form["blockCode"].value
      if blockCodeValue != '000':
        noInputPassed=0
        queryFilter+="p.blockCode = '%s' and " %(blockCodeValue)
      if form.has_key('fpsCode'):
        fpsCodeValue=form["fpsCode"].value
        if fpsCodeValue != '000':
          noInputPassed=0
          queryFilter+="p.fpsCode = '%s' and " %(fpsCodeValue)
  
  if noInputPassed == 1: 
    queryFilter=queryFilter.lstrip(' and')
  queryFilter=queryFilter.rstrip('and ') 
   
  myhtml=""
  myform=getButtonV2("./shopStatus.py", "biharPDS", "Submit") 
  extraInputs=''
  extraInputs+=getInputRow(cur,"distCode",distCodeValue)
  extraInputs+=getInputRow(cur,"blockCode",blockCodeValue,distCodeValue)
  extraInputs+=getInputRow(cur,"fpsCode",fpsCodeValue,distCodeValue,blockCodeValue)
  myform=myform.replace("extrainputs",extraInputs)

  
  query_table=''
  query_table+="<center><h2>Download Status </h2></center>"
  query="select p.distName,p.blockName,p.fpsName,ps.fpsMonth,ps.fpsYear,ps.downloadAttemptDate,ps.statusRemark from pdsShops p, pdsShopsDownloadStatus ps where p.distCode=ps.distCode and p.blockCode=ps.blockCode and p.fpsCode=ps.fpsCode %s limit 30" %(queryFilter)
  query_table += bsQuery2HtmlV2(cur, query)
 
  query_table+="<center><h2>Detailed Information</h2></center>"
  query="select p.distName,p.blockName,p.fpsName,psms.fpsMonth,psms.fpsYear,psms.scheme,psms.status,psms.sioStatus,psms.driverName0,psms.vehicle0,psms.dateOfDelivery0 from pdsShops p, pdsShopsMonthlyStatus psms where p.distCode=psms.distCode and p.blockCode=psms.blockCode and p.fpsCode=psms.fpsCode %s order by dateOfDelivery0 DESC limit 100" %(queryFilter)
  query_table += bsQuery2HtmlV2(cur, query)
 
  myhtml+=myform
  #myhtml+=query
  myhtml+=query_table
 

  myhtml=htmlWrapper(title="Shop Status", head='<h1 aling="center">Bihar PDS Shop Status</h1>', body=myhtml)
  print myhtml.encode('UTF-8')
  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
开发者ID:rajesh241,项目名称:libtech,代码行数:59,代码来源:shopStatus.py


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