插入行

时间:2015-08-07 10:13:32

标签: python mysql

我想在每个插入行之后调用一个函数但是不执行该函数。我正在尝试将图像分配给mysql id。我只想在插入行时调用该函数。

def insert_entry(self, camId, camName, vrm, entryDatetime, milliSecs, nationality, filename):
                myFilename = "/tmp/%s" % filename

                sql = """INSERT INTO %s (camera_id, name, plate, datetime, millisecs, nationality, image_name,checked)
                values ("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s") """ % (tableName,
                                                               camId,
                                                               camName,
                                                               vrm,
                                                               entryDatetime,
                                                               milliSecs,
                                                               nationality,
                                                               filename,
                                                               checked)
                # print sql
                retVal = self.cursor.execute(sql)

                # Now get the id of the entry we have just created
                sql = """SELECT id FROM %s ORDER BY id DESC""" % tableName
                self.cursor.execute(sql)

This is the function  to be called:

function etCommonGetImagePath($conn, $camName, $id) {
    $serverDir = $_SERVER['DOCUMENT_ROOT'];
    $imagesTop = "/cam_images";


return $webPath;

0 个答案:

没有答案