示例#1
0
def get_number_of_parking_place(serverIp):

    sqlConn = connect_db(serverIp, 'root', 'SmartCity@123', 'ipmtest')
    x = sqlConn.cursor()
    x.execute('''SELECT COUNT(*) FROM sm_ipm_park_place''')
    numOfPlace = x.fetchone()[0]
    return numOfPlace
示例#2
0
 def get_slot_id(self, serverIp):
     sqlConn = connect_db(serverIp, 'root', 'SmartCity@123', 'ipmtest')
     x = sqlConn.cursor()
     x.execute('''SELECT id FROM sm_ipm_park_slot WHERE slot_name = %s AND unicode = %s''', (self.name, self.unicode))
     slotId = x.fetchone()
     self.id = slotId[0]
     sqlConn.close()
     return self.id
示例#3
0
def get_block_id(serverIp, placeId, blockName):
    sqlConn = connect_db(serverIp, 'root', 'SmartCity@123', 'ipmtest')
    x = sqlConn.cursor()
    sqlQuery = 'SELECT id FROM sm_ipm_park_block WHERE place_id = %s AND block_name = \'%s\'' % (
        placeId, blockName)
    x.execute(sqlQuery)
    blockId = x.fetchone()[0]
    return blockId
示例#4
0
def delete_parking_place(serverIp, placeName):

    sqlConn = connect_db(serverIp, 'root', 'SmartCity@123', 'ipmtest')
    x = sqlConn.cursor()
    deleteQuery = 'DELETE FROM sm_ipm_park_place WHERE place_name = \'%s\'' % placeName
    x.execute(deleteQuery)
    sqlConn.commit()
    sqlConn.close()
    print 'Deleted parking successul'
示例#5
0
def get_tenant_id(serverIp, placeName, tenantName):
    parkingPlace = get_parking_place_info(serverIp, placeName)
    sqlConn = connect_db(host=serverIp,
                         user='******',
                         password='******',
                         db='ipmtest')
    x = sqlConn.cursor()
    queryCmd = 'SELECT id FROM sm_ipm_place_tenant WHERE place_id = %s AND tenant_name = \'%s\'' % (
        parkingPlace.id, tenantName)
    x.execute(queryCmd)
    tenantId = x.fetchone()[0]
    return tenantId
示例#6
0
def recorded_vehicle(serverIp, veh_no, veh_img, camera, direction):
    sql_conn = connect_db(host=serverIp)
    x = sql_conn.cursor()

    try:
        x.execute(
            """INSERT INTO anpr(vehicle_number, vehicle_image, camera_mac_address, date_time, direction)
                            VALUE(%s,%s,%s,NOW(),%s)""",
            (veh_no, veh_img, camera, direction))
        sql_conn.commit()
        print 'New vehicle is recorded \n'
    except:
        print 'Could not insert the data\n'
        sql_conn.rollback()
    sql_conn.close()
示例#7
0
def get_parking_place_info(serverIp, placeName):
    sqlConn = connect_db(serverIp, 'root', 'SmartCity@123', 'ipmtest')
    x = sqlConn.cursor()
    query = 'SELECT id, lang, lat, unicode, pass_rule, auto_exit FROM sm_ipm_park_place WHERE place_name =\'%s\'' % placeName
    x.execute(query)
    info = x.fetchone()
    sqlConn.close()
    print 'place info: ', info
    parkingPlace = parking_place(placeName=placeName,
                                 unicode=info[3],
                                 placeId=info[0],
                                 longitude=info[1],
                                 latitude=info[2],
                                 passRuleName=info[4],
                                 autoExit=info[5])
    return parkingPlace
示例#8
0
def get_vehicle_not_reconcile(serverIp):
    sql_conn = connect_db(host=serverIp)
    veh_list = []
    x = sql_conn.cursor()
    x.execute(
        """SELECT id, vehicleno, location_id FROM sim.booking WHERE exittime IS NULL"""
    )
    vehicles = x.fetchall()
    for veh in vehicles:
        vehi = vehicle()
        vehi.vehicleNo = veh[1]
        vehi.vehicleImage = ' '
        print 'test print veh No: ', veh[1]
        veh_list.append(vehi)

    sql_conn.close()
    return veh_list