Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8553705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:42:51+00:00 2026-06-11T14:42:51+00:00

# -*- coding: utf-8 -*- import os import time import re import urllib import

  • 0
# -*- 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 !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:42:52+00:00Added an answer on June 11, 2026 at 2:42 pm

    You have pasted part of the code that couldn’t produce the error that you have stated. Here is the re-written version:

    import MySQLdb
    from getpass import getpass
    
    hostip = raw_input("Input your sql Ip:")
    username = raw_input("Input your sql username:")
    password = getpass("Input your password:")
    dbname = raw_input("Input your dbname :")
    
    conn = MySQLdb.connect(hostip, username, password, dbname)
    cur = conn.cursor()
    cur.execute("SHOW TABLES")
    tablenames = [i[0] for i in cur.fetchall()]
    print tablenames
    

    Run this and only this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

# -*- coding: utf-8 -*- # -*- coding: iso-8859-9 -*- import urllib2 import urllib
#!/usr/bin/python # -*- coding: utf-8 -*- import sys import os import cgi import string
here is my code #!/usr/bin/python # -*- coding:utf-8 -*- import sys import pysvn def
#!/usr/bin/env python # -*- coding: utf-8 -*- import re text = aaaa[ab][cd][ef] a =
#!/usr/bin/env python # -*- coding: utf-8 -*- import curses screen = curses.initscr() curses.noecho() curses.curs_set(0)
I have a script like this: #!/Python26/ # -*- coding: utf-8 -*- import sys
Example code: # -*- coding: utf-8 -*- from functools import wraps class MyClass(object): def
I have this code: # -*- coding: utf-8 -*- import random import os, glob
I have this code: # -*- coding: utf-8 -*- import random import os, glob
# -*- coding: utf-8 -*- import string s = uDobre uczynki są jak dobre

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.