Пример #1
0
Файл: db.py Проект: fanlu/MyApp
 def update(self, p_table_name, p_data, p_where):
     for key in p_data:
         p_data[key] = func_ext.addslashes(func_ext.uni_str(p_data[key]))
     for key in p_where:
         p_where[key] = func_ext.addslashes(func_ext.uni_str(p_where[key]))
     edit_sql = ",".join(["%s='%s'" % (str(x[0]), str(x[1])) for x in p_data.items()])
     where_sql = " AND ".join(["%s='%s'" % (str(x[0]), str(x[1])) for x in p_where.items()])
     real_sql = "UPDATE %s SET %s WHERE %s" % (p_table_name, edit_sql, where_sql)
     return self.query(real_sql)
Пример #2
0
Файл: db.py Проект: fanlu/MyApp
 def replace(self, p_table_name, p_data):
     for key in p_data:
         p_data[key] = func_ext.addslashes(func_ext.uni_str(p_data[key]))
     key = "`,`".join(p_data.keys())
     value = "','".join(p_data.values())
     real_sql = "REPLACE INTO %s (`%s`) VALUES ('%s')" % (p_table_name, key, value)
     return self.query(real_sql)
Пример #3
0
Файл: db.py Проект: fanlu/MyApp
 def isinstance(self, p_table_name, p_where):
     for key in p_where:
         p_where[key] = func_ext.addslashes(func_ext.uni_str(p_where[key]))
     where_sql = " AND ".join([x[0] + "='" + x[1] + "'" for x in p_where.items()])
     real_sql = "SELECT count(*) as cnt FROM " + p_table_name + " WHERE " + where_sql
     if self.query(real_sql):
         res = self.fetch_assoc()
         return res[0]
     else:
         return 0
Пример #4
0
Файл: db.py Проект: fanlu/MyApp
 def delete(self, p_table_name, p_where):
     for key in p_where:
         p_where[key] = func_ext.addslashes(func_ext.uni_str(p_where[key]))
     where_sql = " AND ".join(["%s='%s'" % (x[0], x[1]) for x in p_where.items()])
     real_sql = "DELETE FROM %s WHERE " % (p_table_name, where_sql)
     return self.query(real_sql)