#!/usr/bin/python3
""" script that lists all cities
    from the database hbtn_0e_4_usa
"""

import MySQLdb
import sys


if __name__ == "__main__":
    if len(sys.argv):
        username = sys.argv[1]
        password = sys.argv[2]
        database = sys.argv[3]
    db = MySQLdb.connect(host='localhost',
                         user=username, passwd=password, db=database)
    cur = db.cursor()
    cur.execute('''SELECT cities.id, cities.name,
                states.name FROM cities INNER JOIN
                states ON cities.state_id = states.id''')
    for row in cur.fetchall():
        print(row)
    cur.close()
    db.close()
