1234567891011121314151617181920212223242526272829303132333435363738 |
- def index_value(data, value):
- try:
- index = data.index(value)
- except ValueError:
- index = -1
- return index
- def delete_table(database, table, where=None):
- if where is not None:
- wheres = " where "
- for key in where:
- wheres = wheres + key + " = " + where[key] + " and "
- wheres = wheres[:-5]
- else:
- wheres = ""
- return "delete from " + database + "." + table + wheres + ";"
- def insert_table(database, table, fields, values):
- return "insert into " + database + "." + table + " (" + fields + ") values (" + values + ");"
- def get_values(list_values):
- values = ""
- for value in list_values:
- if isinstance(value, str) and not value == "now()" and not value == "null":
- values = values + "\'" + value + "\', "
- else:
- values = values + str(value) + ", "
- return values[:-2]
- def get_values_delete(list_values):
- values = {}
- for value in list_values:
- if isinstance(list_values[value], str) and not list_values[value] == "now()":
- values[value] = "'" + list_values[value] + "'"
- else:
- values[value] = str(list_values[value])
- return values
|