# -*- coding: utf-8 -*-
import os
import time
import re
import urllib
import urllib2
import MySQLdb
hostip = raw_input("Input your sql Ip:")
username = raw_input("Input your sql username:")
password = raw_input("Input your password:")
dbname = raw_input("Input your dbname :")
conn = MySQLdb.connect(host = hostip, user = username, passwd = password, db = dbname)
cur = conn.cursor()
cur.execute("show tables")
alltable = cur.fetchall()
tablenames = []
for i in range(len(alltable)):
for j in range(len(alltable[i])):
tablenames.append(alltable[i][j])
print tablenames
Above is my code, need pass the input args to access the mysql connect, but i can’t print the tables name use the program, can someone help me with that?
thank you very much !
You have pasted part of the code that couldn’t produce the error that you have stated. Here is the re-written version:
Run this and only this.