apollo_moon_driver Posted July 6, 2014 Share Posted July 6, 2014 i have a dictionary - THIS IS obviously a python dictionaryan this has approx 8 000 lines with records[/code]$ python printer.py{'url': 'http://www.site1_com' 'cname': 'butcher', 'name': 'cheng', 'email': 'mail1@hotmail.com'}{'url': 'http://www.site2_com' 'cname': 'dilbert', 'name': 'James', 'email': 'mail2@hotmail.com'} i have a mysql-db up and runing in my opensusethere i have created a db with the fieldsurlcnamenameemaili use theimport MySQLdbi studied this documentation here: http://stackoverflow.com/questions/372885/how-do-i-connect-to-a-mysql-database-in-pythonbut i think this goes a bit over my head.- well how can i get the data ( in other words the dictionary) into the database?love to hear from yougreetings Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted October 25, 2014 Share Posted October 25, 2014 Have a look at Mysql Connector/Python MySQL Connector/Python enables Python programs to access MySQL databases Coding examples Quote Link to comment Share on other sites More sharing options...
rahuldev2910 Posted August 4, 2018 Share Posted August 4, 2018 (edited) Use MySQL Connector Python because it is official Oracle driver for MySQL for working with Python and it works with both Python 3 and Python 2 You need to match your dictionary key to your MySQL table column. Please follow these steps : - Connect to MySQL from Python - Connect to MySQL through Python Use parameterized Querty to insert different data tuples using the same query to increase the performance. Refer - Insert data into MySQL Table using Python Refer - How to Use parameterized Query You need Edited August 4, 2018 by Barand Links removed Quote Link to comment Share on other sites More sharing options...
Barand Posted August 4, 2018 Share Posted August 4, 2018 Don't resurrect old posts. The poster of that question hasn't been back here for four years. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.