本文整理汇总了Python中DBManager.DBManager类的典型用法代码示例。如果您正苦于以下问题:Python DBManager类的具体用法?Python DBManager怎么用?Python DBManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DBManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: namotoring_user_grab
def namotoring_user_grab(url, userdb = 'namotoring_users', debug = False):
bimm = namotoring()
main_page = xmlTree_w_login(url,'vb', 'somebody', 'anybody')
userdata = []
#pdb.set_trace()
if main_page:
if not debug:
udb = DBManager()
if len(main_page.xpath(bimm.location))>0:
#print bimm.get_location(main_page.xpath(bimm.location)[0].text_content().strip())
userdata.append(('Location',bimm.get_location(main_page.xpath(bimm.location)[0].text_content().strip())))
#if len(main_page.xpath(bimm.cars))>0:
# print main_page.xpath(bimm.cars)[0].text_content()
if len(main_page.xpath(bimm.interests))>0:
#print main_page.xpath(bimm.interests)[0].text_content()
userdata.append(('Interests',main_page.xpath(bimm.interests)))
if len(main_page.xpath(bimm.noposts))>0:
#print bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())
userdata.append(('TotalPosts',bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())[0]))
userdata.append(('PostsPerDay',bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())[1]))
if len(main_page.xpath(bimm.lastac))>0:
#print bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content())
userdata.append(('LastActivity',bimm.convert_to_valid_date(bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content()))))
if len(main_page.xpath(bimm.joindate))>0:
#print bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content())
userdata.append(('JoinDate',bimm.convert_to_valid_date(bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content()))))
#if len(main_page.xpath(bimm.ppday))>0:
# print bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())
#if len(main_page.xpath(bimm.cars))>0:
# print bimm.get_cars(main_page.xpath(bimm.cars)[0])
if len(main_page.xpath(bimm.handle))>0:
#print main_page.xpath(bimm.handle)[0].text_content()
userdata.append(('Handle',main_page.xpath(bimm.handle)[0].text_content().strip()))
#if len(main_page.xpath(bimm.bio))>0:
# print main_page.xpath(bimm.bio)[0].text_content()
if len(main_page.xpath(bimm.occupation))>0:
#print main_page.xpath(bimm.occupation)[0].text_content()
try:
userdata.append(('Occupation',main_page.xpath(bimm.occupation)[0].text_content()))
except AttributeError:
userdata.append(('Occupation',main_page.xpath(bimm.occupation)[0]))
if len(main_page.xpath(bimm.ulink))>0:
#print main_page.xpath(bimm.ulink)[0].text_content()
userdata.append(('Link',main_page.xpath(bimm.ulink)[0].text_content()))
if len(main_page.xpath(bimm.name))>0:
#print bimm.get_name_email(main_page.xpath(bimm.name)[0])
userdata.append(('Name',bimm.get_name_email(main_page.xpath(bimm.name)[0])))
#print userdata
if len(main_page.xpath(bimm.plus_fb))>0:
userdata.append(('PositiveFeedback', main_page.xpath(bimm.plus_fb)[0].text_content().strip()))
if len(main_page.xpath(bimm.minus_fb))>0:
userdata.append(('NegativeFeedback', diff(main_page.xpath(bimm.minus_fb)[0].text_content().strip(),\
main_page.xpath(bimm.plus_fb)[0].text_content().strip())))
if not debug:
udb.insert_into_table(userdb, userdata)
udb.close()
else:
print userdata
else:
pass
示例2: compressLocations
def compressLocations(self):
#get updated location data from this nodes session table
self.updateLocations()
#initialize list to hold location rows to delete lID's
#initialize Start and End
locToDel = list()
Start = 0
End = 0
#loop over every location
for index, location in enumerate(self.locations):
#skip the first iteration
if index == 0:
continue
lID = location['lID']
#if location is the same at self.locations[Start]
if self.sameLoc(location, self.locations[Start]):
locToDel.append(lID)
End = index
else:
if not Start == End:
locToDel.pop()
Start = index
End = index
#if there are locations to delete
if locToDel:
#open a connection to the DB
db = DBManager()
#delete the locations that were marked
db.deleteLocByLID(self.sessionTblName, locToDel)
#close the database connection
db.close()
示例3: validateLocations
def validateLocations(self):
#get updated location data from this nodes session table
self.updateLocations()
#initialize list to hold lID's of location rows to delete
locToDel = list()
#loop over every location
for location in self.locations:
lID = location['lID']
locTime = location['time']
locLat = location['lat']
locLon = location['lon']
# if the timestamp is invalid (in the future)
if not self.validTime(locTime):
locToDel.append(lID)
# o.w. if the location is invalid
elif not self.validLoc(locLat, locLon):
locToDel.append(lID)
#if there are locations to delete
if locToDel:
#open a connection to the DB
db = DBManager()
#delete the locations that were marked
db.deleteLocByLID(self.sessionTblName, locToDel)
#close the database connection
db.close()
示例4: IniciarCaja
class IniciarCaja(wx.Dialog):
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title, size=(180,90))
self.DBM = DBManager()
vbox = wx.BoxSizer(wx.VERTICAL)
hbox1 = wx.BoxSizer(wx.HORIZONTAL)
font = wx.Font(16, wx.NORMAL, wx.NORMAL, wx.BOLD)
title = wx.StaticText(self, -1, "Inicio de caja")
title.SetFont( font )
hbox2 = wx.BoxSizer(wx.HORIZONTAL)
self.money = wx.TextCtrl(self, -1, "")
image = wx.Image('green-ok.gif',
wx.BITMAP_TYPE_ANY).ConvertToBitmap()
btn_ini = wx.BitmapButton(self, id=-1, bitmap=image, size=(30,30))
vbox.Add( hbox1 )
vbox.Add( hbox2 )
hbox1.Add( title )
hbox2.Add( self.money )
hbox2.Add( btn_ini )
self.Bind(wx.EVT_BUTTON, self.OnInit, btn_ini)
#self.SetSizerAndFit(vbox)
self.SetSizer(vbox)
self.Show(True)
def OnInit( self, evt ):
dinero = self.money.GetValue()
this_time = datetime.datetime.now().strftime("%m/%d/%y")
self.DBM.addProductTrans( this_time, dinero, 1, 1, 19, 1, 1, 0, 0)
self.Close()
示例5: audiworld_user_grab
def audiworld_user_grab(url, userdb = 'audiworld_users', debug = True):
bimm = audiworld()
main_page = xmlTree(url)
if main_page:
userdata = []
if not debug:
udb = DBManager()
if len(main_page.xpath(bimm.location))>0:
#print main_page.xpath(bimm.location)[0].text_content()
userdata.append(('Location',main_page.xpath(bimm.location)[0].text_content()))
#if len(main_page.xpath(bimm.cars))>0:
# print main_page.xpath(bimm.cars)[0].text_content()
if len(main_page.xpath(bimm.interests))>0:
#print main_page.xpath(bimm.interests)[0].text_content()
userdata.append(('Interests',main_page.xpath(bimm.interests)[0].text_content()))
if len(main_page.xpath(bimm.noposts))>0:
#print bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())
userdata.append(('TotalPosts',bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())))
if len(main_page.xpath(bimm.lastac))>0:
#print bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content())
userdata.append(('LastActivity',bimm.convert_to_valid_date(bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content()))))
if len(main_page.xpath(bimm.joindate))>0:
#print bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content())
userdata.append(('JoinDate',bimm.convert_to_valid_date(bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content()))))
if len(main_page.xpath(bimm.ppday))>0:
#print bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())
userdata.append(('PostsPerDay',bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())))
if len(main_page.xpath(bimm.cars))>0:
#print bimm.get_cars(main_page.xpath(bimm.cars)[0])
userdata.append(('Cars',bimm.get_cars(main_page.xpath(bimm.cars)[0])))
if len(main_page.xpath(bimm.handle))>0:
#print main_page.xpath(bimm.handle)[0].text_content().strip()
userdata.append(('Handle',main_page.xpath(bimm.handle)[0].text_content().strip()))
if len(main_page.xpath(bimm.bio))>0:
#print main_page.xpath(bimm.bio)[0].text_content()
userdata.append(('Biography',main_page.xpath(bimm.bio)[0].text_content()))
if len(main_page.xpath(bimm.occupation))>0:
#print main_page.xpath(bimm.occupation)[0].text_content()
userdata.append(('Occupation',main_page.xpath(bimm.occupation)[0].text_content()))
if len(main_page.xpath(bimm.ulink))>0:
#print main_page.xpath(bimm.ulink)[0].text_content()
userdata.append(('Link',main_page.xpath(bimm.ulink)[0].text_content()))
if not debug:
udb.insert_into_table(userdb, userdata)
udb.close() #@IndentOk
else:
print userdata
else:
pass
示例6: updateLocations
def updateLocations(self):
db = DBManager()
#get this nodes location data
self.locations = db.getLocations(self.sessionTblName, self.nID)
db.close()
#if this node has no locations or is not in a sessions, stop the housekeeping threads
if self.locations is None:
self.keepRunning = False
示例7: updatekladr
def updatekladr(self,listspr):
for spr in listspr:
for row in spr:
query=DBManager.executeSql(u"""select KOD_T_ST from kladr.SOCRBASE where SOCRNAME='{0}' and infisCode='{1}'""".format(spr[row],row))
if len(query)>0:
continue
else:
query=DBManager.executeSqlNonQuery(u"""update kladr.SOCRBASE set infisCode='{1}' where SOCRNAME='{0}'""".format(spr[row],row))
示例8: getdata
def getdata(self):
#stmt=TextFileLoader.load()
DBManager.executeSqlNonQuery(u"""drop procedure if exists `ExportR23PN_proc`;""")
DBManager.executeSqlNonQuery(ConnectionsManager.samsonconn['export_proc'])
query =DBManager.executeproc()
return query
示例9: priuschat_user_grab
def priuschat_user_grab(url, userdb='priuschat_users', debug = False):
bimm = priuschat()
main_page = xmlTree(url)
userdata = []
#pdb.set_trace()
if main_page:
if not debug:
udb = DBManager()
if len(main_page.xpath(bimm.location))>0:
#print main_page.xpath(bimm.location)[0].text_content().strip()
userdata.append(('Location',main_page.xpath(bimm.location)[0].text_content().strip()))
#if len(main_page.xpath(bimm.cars))>0:
# print main_page.xpath(bimm.cars)[0].text_content()
if len(main_page.xpath(bimm.interests))>0:
#print main_page.xpath(bimm.interests)[0].text_content()
userdata.append(('Interests',main_page.xpath(bimm.interests)[0].text_content()))
if len(main_page.xpath(bimm.noposts))>0:
#print bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())
userdata.append(('TotalPosts',bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())))
if len(main_page.xpath(bimm.lastac))>0:
#print bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content())
userdata.append(('LastActivity',bimm.convert_to_valid_date(bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content()))))
if len(main_page.xpath(bimm.joindate))>0:
#print bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content())
userdata.append(('JoinDate', bimm.convert_to_valid_date(bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content()))))
if len(main_page.xpath(bimm.ppday))>0:
#print bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())
userdata.append(('PostsPerDay', bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())))
if len(main_page.xpath(bimm.cars))>0:
#print main_page.xpath(bimm.cars)[0].text_content()
userdata.append(('Cars',main_page.xpath(bimm.cars)[0].text_content()))
if len(main_page.xpath(bimm.handle))>0:
#print main_page.xpath(bimm.handle)[0].text_content()
userdata.append(('Handle',main_page.xpath(bimm.handle)[0].text_content()))
#if len(main_page.xpath(bimm.bio))>0:
# print main_page.xpath(bimm.bio)[0].text_content()
if len(main_page.xpath(bimm.occupation))>0:
#print main_page.xpath(bimm.occupation)[0].text_content()
userdata.append(('Occupation',main_page.xpath(bimm.occupation)[0].text_content()))
if len(main_page.xpath(bimm.ulink))>0:
#print main_page.xpath(bimm.ulink)[0].text_content()
userdata.append(('Link', main_page.xpath(bimm.ulink)[0].text_content()))
#if len(main_page.xpath(bimm.name))>0:
# print bimm.get_name_email(main_page.xpath(bimm.name)[0])
#print userdata
if not debug:
udb.insert_into_table(userdb, userdata)
udb.close()
else:
print userdata
else:
pass
示例10: createNodes
def createNodes(self):
#get data for nodes in the session
db = DBManager()
nodesData = db.getNodes(self.tblName)
db.close()
#create a new Node object for each nodeData row in nodesData
# if such an object does not already exist
for nodeData in nodesData:
if not nodeData['devID'] in self.nodesDict:
#add NodeHandler object to the list of nodes
self.nodes.append(NodeHandler(nodeData))
#add devID key to nodesDict and set to false(not started yet)
self.nodesDict[nodeData['devID']] = False
示例11: vwvortex_grab
def vwvortex_grab(threaddb = 'vwvortex_threads', debug = True):
# pdb.set_trace()
bmw = vwvortex()
main_page = xmlTree(bmw.domain)
lvl1 = main_page.xpath(bmw.linklist_lvl1)
if not debug:
udb = DBManager()
for lvl1_link in lvl1:
second_lvl_page = xmlTree(bmw.domain+lvl1_link)
lvl2 = second_lvl_page.xpath(bmw.linklist_lvl2)
for lvl2_link in lvl2:
next_page = xmlTree(bmw.domain+lvl2_link+alltime)
while True:
try:
next = next_page.xpath(bmw.next_link)[0]
except IndexError:
next = None
threads = next_page.xpath(bmw.threads_list)
tread_data = next_page.xpath(bmw.threaddata)
for j in tread_data:
#pass
if j.xpath(bmw.description):
threaddata = []
threaddata.append(('Description', j.xpath(bmw.description)[0].text_content().encode('utf-8')))
#print j.xpath(bmw.description)[0].text_content().encode('utf-8')
threaddata.append(('Replies', j.xpath(bmw.replies)[0].text_content()))
#print j.xpath(bmw.replies)[0].text_content()
threaddata.append(('Views', bmw.parse_views(j.xpath(bmw.views)[0].text_content())['Views']))
#print bmw.parse_views(j.xpath(bmw.views)[0].text_content())
threaddata.append(('Link', j.xpath(bmw.link)[0].encode('utf-8')))
#print j.xpath(bmw.link)[0].encode('utf-8')
#print bmw.thread_id(j.xpath(bmw.link)[0].encode('utf-8'))
vwvortex_thread_grab(bmw.domain+j.xpath(bmw.link)[0].encode('utf-8'))
if not debug:
udb.insert_into_table(threaddb, threaddata)
else:
print threaddata
#vwvortex_thread_grab()
# for k in threads:
# pass
# print k
if next:
next_page = xmlTree(bmw.domain+next)
elif not next:
break
if not debug:
udb.close()
示例12: audiworld_grab
def audiworld_grab(threaddb = 'audiworld_threads', debug = True):
bmw = audiworld()
main_page = xmlTree(bmw.domain)
lvl1 = main_page.xpath(bmw.linklist)
if not debug:
udb = DBManager()
for lvl1_link in lvl1:
# print lvl1_link
next_page = xmlTree(bmw.domain+lvl1_link+alltime)
#next_page = xmlTree(lvl1_link)
# print bmw.domain+lvl1_link
#next = next_page.xpath(bmw.next_link)[0]
while True:
try:
next = next_page.xpath(bmw.next_link)[0]
except IndexError:
next = None
threads = next_page.xpath(bmw.threads_list)
tread_data = next_page.xpath(bmw.threaddata)
for j in tread_data:
#pass
threaddata = []
if j.xpath(bmw.description):
threaddata.append(('Description',j.xpath(bmw.description)[0].text_content().encode('utf-8')))
#print j.xpath(bmw.description)[0].text_content().encode('utf-8')
threaddata.append(('Replies', j.xpath(bmw.replies)[0].text_content()))
#print j.xpath(bmw.replies)[0].text_content()
threaddata.append(('Views', j.xpath(bmw.views)[0].text_content()))
#print j.xpath(bmw.views)[0].text_content()
threaddata.append(('Link', j.xpath(bmw.link)[0]))
#print j.xpath(bmw.link)[0]
threaddata.append(('ThreadID', bmw.thread_id(j.xpath(bmw.link)[0]) ))
#print bmw.thread_id(j.xpath(bmw.link)[0])
audiworld_thread_grab(bmw.domain+j.xpath(bmw.link)[0])
if not debug:
udb.insert_into_table(threaddb, threaddata)
else:
print threaddata
for k in threads:
pass
print k
if next:
next_page = xmlTree(bmw.domain+next+alltime)
elif not next:
break
if not debug:
udb.close()
示例13: feoa_thread_grab
def feoa_thread_grab(url, postsdb = 'feoa_posts', debug = True):
bimm = feoa()
next_page = xmlTree(url)
#posts = main_page
if not debug:
udb = DBManager()
while True:
try:
next = next_page.xpath(bimm.next_link)[0]
#print next
except IndexError:
next = None
posts = next_page.xpath(bimm.postdata)
for t in posts:
if t.xpath(bimm.posterid):
threaddata = []
#print '**********************************************************************'
threaddata.append(('TimeOfPost',bimm.convert_to_valid_date(bimm.time_of_post(\
t.xpath(bimm.timeofpost)[0].text_content().strip()))))
#print t.xpath(bimm.timeofpost)[0].text_content().strip()
threaddata.append(('PosterID',bimm.poster_id(t.xpath(bimm.posterid)[0])))
#print bimm.poster_id(t.xpath(bimm.posterid)[0])#[0].text_content()
threaddata.append(('PostID',bimm.post_id(t.xpath(bimm.postid)[0])))
#print bimm.post_id(t.xpath(bimm.postid)[0])#[0].text_content()
threaddata.append(('ThreadID', bimm.thread_id(t.xpath(bimm.post_thread)[0])))
try:
threaddata.append(('PostCountInThread',t.xpath(bimm.postcount)[0].text_content()))
#print t.xpath(bimm.postcount)[0].text_content()
except AttributeError:
threaddata.append(('PostCountInThread',t.xpath(bimm.postcount)[0]))
#print t.xpath(bimm.postcount)[0]
except IndexError:
pass
threaddata.append(('Link',t.xpath(bimm.postlink)[0] ))
feoa_user_grab(bimm.domain+t.xpath(bimm.posterid)[0], 'feoa_users')
if not debug:
udb.insert_into_table(postsdb, threaddata)
else:
print threaddata
#print t.xpath(bimm.postlink)#[0].text_content()
#print '**********************************************************************'
if next:
#pdb.set_trace()
next_page = xmlTree(bimm.domain+next+alltime)
elif not next:
if not debug:
udb.close()
break
示例14: mazda3_grab
def mazda3_grab(threaddb = 'mazda3_threadas', debug =True):
#pdb.set_trace()
bmw = mazda3()
main_page = xmlTree(bmw.domain)
lvl1 = main_page.xpath(bmw.linklist)
if not debug:
udb = DBManager()
for lvl1_link in lvl1:
next_page = xmlTree(lvl1_link)
count = 0
pos = lvl1_link.find('board=') + len('board=')
part = lvl1_link[:pos]
fid = lvl1_link[pos:]
ifid = fid.split(r'.')
try:
lastpage = int(next_page.xpath(bmw.last_page_threads)[0].text_content())
except IndexError:
lastpage = 1
while count<lastpage:
#threads_list = next_page.xpath(bmw.threaddata)
threads = next_page.xpath(bmw.threads_list)
tread_data = next_page.xpath(bmw.threaddata)
for j in tread_data:
#pass
threaddata = []
if j.xpath(bmw.description):
threaddata.append(('Description',j.xpath(bmw.description)[0].text_content().encode('utf-8')))
#print j.xpath(bmw.description)[0].text_content().encode('utf-8')
threaddata.append(('Views', bmw.parse_stats(j.xpath(bmw.stats)[0].text_content())['Views']))
threaddata.append(('Views', bmw.parse_stats(j.xpath(bmw.stats)[0].text_content())['Replies']))
# print bmw.parse_stats(j.xpath(bmw.stats)[0].text_content())
#print j.xpath(bmw.views)[0].text_content()
threaddata.append(('Link', j.xpath(bmw.link)[0]))
# print j.xpath(bmw.link)[0]
mazda3_thread_grab(bmw.thread_id(j.xpath(bmw.link)[0]))
if not debug:
udb.insert_into_table(threaddb, threaddata)
#pass
else:
print threaddata
count += 1
print count
print part+addto(ifid,count)
next_page = xmlTree(part+addto(ifid,count))
if not debug:
udb.close()
示例15: getSMO
def getSMO(self):
stmt=u"""select infisCode,shortName from Organisation where id in (select insurer_id from clientpolicy
where insurer_id is not null
group by insurer_id)"""
query = DBManager.executeSql(stmt)
return query