コード例 #1
0
def insertCoordinate(sql_select, sql_select_count, insertTable):
    coordinateDic = getCoordinateDic(sql_select, sql_select_count)

    conn = sqlHelper.getMySQLConn()
    sql_insert = sqlHelper.genInsertSQL(insertTable, 3)

    for x in coordinateDic.keys():
        for y in coordinateDic[x].keys():
            count = coordinateDic[x][y]
            sqlHelper.execWithValues(conn, sql_insert, [x, y, count])

    sqlHelper.closeConn(conn)
コード例 #2
0
def migrationLamost(insertTable, sql_filter, colCount=40):
    sql_fields = "specid,obsdate,mjd,planid,spid,fiberid,dataversion,specpath"
    sql_fields += ",objra,objdec,final_class,final_subclass,final_z,final_z_err,snru,snrg,snrr,snri,snrz"
    sql_fields += ",teff,teff_err,teff_err_c,teff_err_cs"
    sql_fields += ",logg,logg_err,logg_err_c,logg_err_cs"
    sql_fields += ",feh,feh_err,feh_err_c,feh_err_cs"
    sql_fields += ",rv,rv_err,rv_err_c,rv_err_cs"
    sql_fields += ",method,exetime"
    sql_from_dr2 = "dr2.spec_info left join dr2.param_info on dr2.spec_info.specid =dr2.param_info.specid"
    sql_from_dr3 = "dr3.dr3_alpha left join dr3.param_alpha on dr3.dr3_alpha.specid =dr3.param_alpha.specid"

    sql_insert = sqlHelper.genInsertSQL(insertTable, colCount)

    sql_fields_dr2 = "dr2.spec_info." + sql_fields + ",0 as distance,2 as dr"
    sql_fields_dr3 = "dr3.dr3_alpha." + sql_fields + ",distance,3 as dr"
    sql_select_dr2 = sqlHelper.genSelectSQL(sql_fields_dr2, sql_from_dr2, sql_filter)
    sql_select_dr3 = sqlHelper.genSelectSQL(sql_fields_dr3, sql_from_dr3, sql_filter)

    importLamostData(sql_select_dr2, sql_insert)
    importLamostData(sql_select_dr3, sql_insert)
コード例 #3
0
def migrationSDSS(filePath, tableName, colCount, blankColCount=0):
    sql_insert = sqlHelper.genInsertSQL(tableName, colCount)

    data = open(filePath)
    conn = sqlHelper.getMySQLConn()

    count = 0

    for row in data:
        cols = row.split(",")

        if blankColCount > 0:
            for i in range(blankColCount):
                cols.append("")

        sqlHelper.execWithValues(conn, sql_insert, cols)

        count += 1
        if count % 10000 == 0:
            print(count)

    sqlHelper.closeConn(conn)
コード例 #4
0
ファイル: FitsHandler.py プロジェクト: zdwdong/MyCodeLib
 def preHandle(self):
     self.sql_insert = sqlHelper.genInsertSQL(self.insertTable, 20)
     self.conn = sqlHelper.getMySQLConn()