Select Array from MySQL in Python without For Loop -


i trying select array of values mysql without using loop. loop takes long , want grab of values @ once. not know wrong arguments , having hard time interpreting error message receive means.

zipcode = ["37204", "60964", "60068"] connection = mysqldb.connect(host="localhost", user="root", passwd="password", db="database", cursorclass=mysqldb.cursors.sscursor) cursor = connection.cursor()   query = "select fips zip = %s" cursor.executemany(query,zipcode) results = cursor.fetchall() 

the error looks this:

query = query % tuple([db.literal(item) item in args]) typeerror: not arguments converted during string formatting 

any appreciated.

python not forte , i've not used executemany before, don't think it's supposed used executing code that's supposed return something. want use in query.

query = "select fips zip in ('%s')" % "','".join(zipcode) cursor.execute(query) results = cursor.fetchall() 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -