tables=$(mysql -h${host_name} -u${user_name} -p${password}-e"SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA='${db_name}' AND ENGINE='MyISAM';")
for table in${tables} do if [ ${table} != 'TABLE_NAME' ]; then# 排除标题 echo${table} mysql -h${host_name} -u${user_name} -p${password}-e"ALTER TABLE ${db_name}.${table} ENGINE='InnoDB';" fi done
If you hit this problem and don’t want to understand what’s going on, don’t reopen this ticket, just do this:
RECOMMENDED SOLUTION: close the connection with from django.db import connection; connection.close() when you know that your program is going to be idle for a long time.
CRAPPY SOLUTION: increase wait_timeout so it’s longer than the maximum idle time of your program.
In this context, idle time is the time between two successive database queries.
defformat_header_param(name, value): """ Helper function to format and quote a single header parameter.
Particularly useful for header parameters which might contain non-ASCII values, like file names. This follows RFC 2231, as suggested by RFC 2388 Section 4.4.
:param name: The name of the parameter, a string expected to be ASCII only. :param value: The value of the parameter, provided as a unicode string. """ ifnot any(ch in value for ch in'"\\\r\n'): result = '%s="%s"' % (name, value) try: result.encode('ascii') except UnicodeEncodeError: pass else: return result ifnot six.PY3: # Python 2: value = value.encode('utf-8') value = email.utils.encode_rfc2231(value, 'utf-8') value = '%s*=%s' % (name, value) return value