Thursday, 3 December 2015

DB connection

db = MySQLdb.connect(host="205.23.1.45",user="testuser",db="nameofdb",port=3306,passwd="pwd")
        with db:
            cur = db.cursor()
               cur.execute("select * from abc where def=%s",order_no)
            rows = cur.fetchone()
            my_result=rows[0]
            self.assertEqual('101',str(rows[1]) )

No comments:

Post a Comment