How to retrieve table names in a mysql database with Python and MySQLdb?

To be a bit more complete: import MySQLdb connection = MySQLdb.connect( host=”localhost”, user=”myself”, passwd = ‘mysecret’) # create the connection cursor = connection.cursor() # get the cursor cursor.execute(“USE mydatabase”) # select the database cursor.execute(“SHOW TABLES”) # execute ‘SHOW TABLES’ (but data is not returned) now there are two options: tables = cursor.fetchall() # return data … Read more

django.core.exceptions.ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured

You must define the relevant variable to show where your settings.py file lives: export DJANGO_SETTINGS_MODULE=mysite.settings This is the relevant docs entry: When you use Django, you have to tell it which settings you’re using. Do this by using an environment variable, DJANGO_SETTINGS_MODULE. The value of DJANGO_SETTINGS_MODULE should be in Python path syntax, e.g. mysite.settings. Note … Read more

What is PyMySQL and how does it differ from MySQLdb? Can it affect Django deployment?

PyMySQL and MySQLdb provide the same functionality – they are both database connectors. The difference is in the implementation where MySQLdb is a C extension and PyMySQL is pure Python. There are a few reasons to try PyMySQL: it might be easier to get running on some systems it works with PyPy it can be … Read more

Python MYSQL update statement

It should be: cursor.execute (“”” UPDATE tblTableName SET Year=%s, Month=%s, Day=%s, Hour=%s, Minute=%s WHERE Server=%s “””, (Year, Month, Day, Hour, Minute, ServerID)) You can also do it with basic string manipulation, cursor.execute (“UPDATE tblTableName SET Year=%s, Month=%s, Day=%s, Hour=%s, Minute=%s WHERE Server=”%s” ” % (Year, Month, Day, Hour, Minute, ServerID)) but this way is discouraged … Read more