def sql_listusers(hostname, dbusername, dbpassword, dbbase, dbasename): try: conn = MySQLdb.connect (host = hostname, user = dbusername, passwd = dbpassword, db = dbbase) cursor = conn.cursor () cursor.execute (""" use %s """, (dbasename)) # <--- here is the problem
> Everything works fine in this function, except that fact that the > (dbasename) variable is not accepted. I don't know why.. What error are you getting. Are you sure the value in dbasename is *exactly* the same as the version that worked with a hard coded value? > version of the program did not use a variable there. Is there any > obvious mistake that I can't see? Given that we can't see what you are passing into the function its hard to tell. On a general note, given that your function claims to list users it would seem reasonable that you could already have a connection to the database and you would want to pass that in rather than do all the connect stuff inside the function. Otherwise you will have to close the database connection before listing the users etc. That seems pretty inconvenient to me. I'd expect the function interface to look more like: def sql_listUsers(dbConnection, dbName): ... Just a thought, Alan G. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor