yuliji
4/19/2016 - 7:30 AM

python db cursor fetch all

python db cursor fetch all

import MySQLdb
import getpass

#pip install mysql-python

user = raw_input("username: ")
print user
password = getpass.getpass("input the password: ")



dbmk = MySQLdb.Connect('db1',
                     user, password, 'btcchina_mk')

dbphpbb = MySQLdb.Connect('db2',
                     user, password, 'btcchina_mk')

c_mk = dbmk.cursor()
c_mk.execute("""select user_id, phone, phone_country from userdata where user_id = %s""", (2,))

for userdata in c_mk.fetchall():
    print userdata