Changeset 38837 for trunk/ippToPsps/jython/ipptopspsdb.py
- Timestamp:
- Oct 10, 2015, 12:40:44 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/ipptopspsdb.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/ipptopspsdb.py
r38763 r38837 914 914 915 915 ''' 916 Returns boolean value for this column in clients table 917 ''' 918 def existsClient(self, host, pid): 919 920 sql = "SELECT id FROM clients WHERE host = '" + host + "' AND pid = " + str(pid) + " LIMIT 1" 921 922 try: 923 rs = self.executeQuery(sql) 924 if rs.first() is False: return False 925 except: 926 self.logger.exception("Unable to check if " + host + "-" + str(pid) + " is in clients table") 927 928 return True 929 930 ''' 916 931 Update clients, or inserts it for the first time 917 932 ''' 918 933 def updateClient(self, type, host, pid): 919 934 920 try: 935 if self.existsClient(host, pid): 936 self.execute("UPDATE clients SET timestamp = now() WHERE host = '" + host + "' AND pid = " + str(pid)) 937 else: 921 938 self.insertClient(type, host, pid) 922 except:923 self.execute("UPDATE clients SET timestamp = now() WHERE host = '" + host + "' AND pid = " + str(pid))924 939 925 940 ''' … … 1337 1352 1338 1353 for id in ids: 1339 sql = "INSERT IGNORE INTO pending \ 1354 # why is there an IGNORE here? we have deleted old versions already above 1355 sql = "INSERT INTO pending \ 1340 1356 (box_id, batch_type, stage_id) \ 1341 1357 VALUES \ 1342 1358 (" + str(box_id) + ", '" + batchType + "', " + str(id) + ")" 1343 1359 1344 print sql 1345 try: self.execute(sql) 1346 except: 1347 print "failed to insert into pending" 1348 print "sql: " + sql 1349 raise 1360 self.execute(sql) 1350 1361 1351 1362 ''' … … 1656 1667 def storeAllItems(self, rows): 1657 1668 1658 try: 1659 self.execute("DROP TABLE all_pending") 1660 except: 1661 pass 1669 self.dropTable("all_pending") 1662 1670 1663 1671 self.execute("CREATE TEMPORARY TABLE all_pending (stage_id bigint(20), ra_bore float, dec_bore float)") 1664 1672 for row in rows: 1665 1666 1673 try: 1667 1674 sql = "INSERT INTO all_pending (stage_id, ra_bore, dec_bore) \ … … 1678 1685 ''' 1679 1686 def storeAllItemsInDvodb(self, rows, dvo_db, batchType): 1680 1681 #try:1682 # self.execute("DROP TABLE all_pending")1683 #except:1684 # pass1685 1687 1686 1688 #self.execute("CREATE TEMPORARY TABLE all_pending (stage_id bigint(20), ra_bore float, dec_bore float)") … … 1699 1701 #self.logger.infoPair("Items written to Db", "%d" % count) 1700 1702 1701 1702 1703 1703 ''' 1704 1704 Gets all items in the all_pending temporary table within the bounds of this box
Note:
See TracChangeset
for help on using the changeset viewer.
