Re: Connector for python 3.5 in Windows
Is this your problem ,
You cannot use
# connect to mysql database program.
import mysql.connector
cnx = mysql.connector.connect(user = 'test', host = '127.0.0.1', database = 'dbname')
cursor = cnx.cursor()
# Querting my database
query = (" SELECT * FROM tablename")
cursor.execute(query)
for (cy) in cursor:
print('{}'.format(cy))
cursor.close()
cnx.close()
if so , than I suggest you use the following as I had to :
import MySQLdb
db = MySQLdb.connect(host="localhost",user="root",passwd="yourpassword here",db="your database name here")
cur = db.cursor()
cur.execute("SELECT * FROM your DBtablename")
#Querying my database
# open a file handler for the file to write to the database
fo= open('RawData1.csv','w')
for row in cur.fetchall():
output = (row[5] + ',' + row[6]+ ',' + row[7] + ',' + row[8] + ',' + row[9] + ',' + row[17] + ',' + row[17])
print(output)
fo.write(output)
db.close()
Hope this helps