def update_reco_img_table(): imgdict = get_reco_img(recoimagepath) sqls = list() for name, imgs in imgdict.items(): for img in imgs: print img sql = joint_sql_update_reco_img_table(name, img) sqls.append(sql) SQLObject.execute_sqls(sqls)
def update_reco_info_table(logpath): data = get_data_from_log(logpath) sqls = list() for item in data: sql = joint_update_info_table(tool.reco_info, item['name'], item['finddatetime'], item['address'], item['confidence'], item['findtime'], item['img'], item['filename']) sqls.append(sql) SQLObject.execute_sqls(sqls)
def create_img_table(table_name): sql = '''create table if not exists %s ( id int unsigned not null auto_increment primary key, name varchar(40) not null, img varchar(100) not null, unique(name, img) );''' % table_name SQLObject.execute_sql(sql)
def create_info_table(table_name): sql = '''create table if not exists %s ( id int unsigned not null auto_increment primary key, name varchar(40) not null, index(name), finddatetime datetime not null, address varchar(100) not null, confidence varchar(10) not null, findtime varchar(20) not null, img varchar(100) not null, filename varchar(100) not null, unique(name, confidence, findtime, img, filename) );''' % table_name SQLObject.execute_sql(sql)
def select_data_by_filename(table, name, filename): sql = 'select * from %s where name = "%s" and filename = "%s"' % ( table, name, filename) result = SQLObject.select_sql(sql) return result
def select_img_by_name(table, name): sql = 'select img from %s where name = "%s"' % (table, name) result = SQLObject.select_sql(sql) return result
def select_data_by_address(table, name, address): sql = 'select * from %s where name ="%s" and address = "%s" ' % ( table, name, address) result = SQLObject.select_sql(sql) return result