Sunday, 15 March 2015

python - compare 2 tables and print similar data -



python - compare 2 tables and print similar data -

consider, have 2 tables.i wanted attain similar info both tables , print respective values.

cars:

**abs** skoda bmw benz

filename1:

no. v1 v2 v3 1 sport bmw high 2 audi medium 3 posh high benz

problem:even 2 same values nowadays in both tables,its not printing values in v1 when have same names: here ouputs else part though true.

expected output:

bmw posh

program:

import mysqldb db = mysqldb.connect(host="localhost", # host, localhost user="root", # username passwd="mysql", # password db="sakila") # name of info base of operations cursor = db.cursor() cursor.execute("select abs cars") cursor1 = db.cursor() cursor1.execute("select * filename1") in cursor.fetchall(): i1 in cursor1.fetchall(): if in i1: print i1[1] else: print i[0]

please help! answers appreciated!

python mysql

No comments:

Post a Comment