import MySQLdb def get_cursor(): host = 'localhost' user = 'webqtl' passwd = 'webqtl' db = 'db_webqtl' con = MySQLdb.Connect(db=db, host=host, user=user, passwd=passwd) cursor = con.cursor() return cursor