Project

General

Profile

des-ingest-hosts.py

Chris D'Andrea, 10/15/2013 05:12 PM

 
1
#Code to ingest ALL HOSTS into the ATC.
2
#This does no checking with the ATC as to whether or not 
3
#  the host has already been uploaded.
4

    
5
import cx_Oracle
6
import sys
7
import os
8
import math
9
import atc_funcs
10

    
11
hostname = 'leovip148.ncsa.uiuc.edu'
12
port = 1521
13
dbname = 'dessci'
14
username = 'snwriter'
15
password = 'sn4rite'
16

    
17
dsn = cx_Oracle.makedsn(hostname, port, service_name = dbname)
18
connection = cx_Oracle.Connection(username, password, dsn)
19
cursor=connection.cursor()
20

    
21

    
22
#----------------------------------------------------------------------------------
23
query  = "SELECT transient_name,COADD_OBJECTS_ID,ra,dec from SNGALS"
24
query += " where host=1 and GALFLAG=1"
25

    
26
cursor.execute(query)
27
data=cursor.fetchall()
28

    
29
print len(data)
30

    
31
connection.close()
32

    
33
for i,item in enumerate(data):
34
    if i%10 == 0:
35
        print i
36
    name = "SVA1_COADD-"+str(item[1])
37
    atc_funcs.incept_target(name,item[2],item[3])
38
    atc_funcs.post_host(str(item[0]),name)
39

    
40