Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install python MySQLdb to python3 not python

i have Ubuntu and installed python3 since my script is written in it. Since I use MYSQL with MySQLdb, I installed

apt-get install python-mysqldb

however this installed MySQLdb to Python (which is 2.6 on Ubuntu) and not to Python3.

  1. How can I install MySQLdb for Python3
  2. Should I use it at all or switch to PyMSQL

Sorry, I have just started working with Python today...

like image 613
user670186 Avatar asked Feb 05 '12 02:02

user670186


1 Answers

1- You can use this command sudo apt-get install python3-mysqldb

It worked for me.

2- also you can install pip install PyMySQL.

Then add lines to __init__.py file

# __init__.py file

import pymysql
pymysql.install_as_MySQLdb()
like image 141
Aly Radwan Avatar answered Sep 22 '22 15:09

Aly Radwan