2

I need a way to connect my databases in WAMP server MySQL 5.7 to Python 3.8 .

I use MySQL 8.0 in my computer. I am facing the issue in another system where there is no MySQL but only WAMP server MySQL 5.7

Which Module should I be using?

I tried installing mysql.connector module in the other system but learnt later on that it supports MySQL 8.0 downloaded from www.mysql.org only.

Which module should be installed for a satisfactory connection with WAMP server MySQL and Python 3.8?

My code works perfectly without any issues in my computer with the normal MySQL 8.0.

I have figured out a solution for Python 2 which is by using the module MySQLdb. But it does not support Python 3. I wish to know if there are other modules than these

I am sorry for being hasty, but I wish to receive an answer at the earliest. My project depends on it. Thank You in advance.

Power Niru
  • 31
  • 4
  • @Sargis Gevorgyan Thank You For your edit proposal – Power Niru Feb 18 '20 at 13:17
  • So which version of MySQL are you using in WAMPServer, there are not many recent versions that you cannot install in WAMPServer – RiggsFolly Feb 19 '20 at 15:20
  • mysql version is 5.7 in wampserver but 8.0 normally..Hope it helps – Power Niru Feb 20 '20 at 11:13
  • So download the version of MySQL you want to use, there are lots of addons availaible. See [The backup repo](http://wampserver.aviatechno.net/?lang=en) Its easier to navigate than the SourceForge mess – RiggsFolly Feb 20 '20 at 11:21
  • Actually my code works perfectly in my computer. The issue is faced in another system in my school where only `WAMP` is installed. – Power Niru Feb 20 '20 at 11:29
  • I am aware that `WAMP` has released a `MySQL 8.0` version but I just can not ask my school teachers to install new updates for the computer in my school. – Power Niru Feb 20 '20 at 11:31
  • So is this any use https://stackoverflow.com/questions/372885/how-do-i-connect-to-a-mysql-database-in-python – RiggsFolly Feb 20 '20 at 11:36
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/208181/discussion-between-power-niru-and-riggsfolly). – Power Niru Feb 20 '20 at 11:37

1 Answers1

1

I am grateful you came here!

Actually there was a DLL error linked to WAMP. Once I rectified it, I reinstalled pymysql through pip.

Now pymysql works just fine. Make sure you have the right dll files installed in your computer.

Use mysql module for the default MySQL

Use pymysql module for WAMP.

Also notice the difference in syntax for the two modules:

import pymysql
db = pymysql.connect('host', 'username', 'password')
dbcur = db.cursor()
import mysql.connector
db = mysql.connector.connect(username='username', passwd='password',
                             host='host', database = 'dbname')
dbcur = db.cursor()
Power Niru
  • 31
  • 4