@@ -0,0 +1,939 @@
+#!/usr/bin/python%0A%0A# Some simple SQL helpers%0A%0Aimport datetime%0Aimport utility%0Aimport unicodedata%0A%0A%0Aclass FormatException(Exception):%0A  %22%22%22 FormatException -- Used for reporting failures for format DB values %22%22%22%0A%0A%0Adef FormatSqlValue(name, value):%0A  %22%22%22FormatSqlValue -- some values get escaped for SQL use%22%22%22%0A%0A  if type(value) == datetime.datetime:%0A    return ('STR_TO_DATE(%22%25s%22, %22%25s%22)'%0A            %25(value.strftime('%25a, %25d %25b %25Y %25H:%25M:%25S'),%0A              '''%25a, %25d %25b %25Y %25H:%25i:%25s'''))%0A%0A  if name == 'date':%0A    return 'STR_TO_DATE(%22%25s%22, %22%25s%22)' %25(value, '''%25a, %25d %25b %25Y %25H:%25i:%25s''')%0A%0A  if type(value) == long or type(value) == int:%0A    return '%25d' %25 value%0A%0A  if value == '':%0A    return '%22%22'%0A%0A  if value is None:%0A    return 'NULL'%0A%0A  try:%0A    return '%22%25s%22' %25 utility.Normalize(value).replace('%22', '%22%22')%0A  except Exception, e:%0A    raise FormatException('Could not format string value %25s = %25s (%25s)'%0A                          %25(name, value, e))%0A

Add sql helpers.