mysql db connection using python - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: mysql db connection using python (/thread-9621.html) Pages:
1
2
|
RE: mysql db connection using python - snippsat - Apr-21-2018 There no need to use package from distro,use as recommend PyMySQL(Pure Python MySQL Driver). I use pyenv,so my python and pip is set to 3.6 Normal for Python 3 without pyenv is to use pip3 pip3 install PyMySQL .# Test python and pip mint@mint ~/mp3_env $ pip -V pip 9.0.1 from /home/mint/.pyenv/versions/3.6.4/lib/python3.6/site-packages (python 3.6) mint@mint ~/mp3_env $ python -V Python 3.6.4 # Install mint@mint ~/mp3_env $ pip install PyMySQL Collecting PyMySQL Using cached https://files.pythonhosted.org/packages/e5/07/c0f249aa0b7b0517b5843eeab689b9ccc6a6bb0536fc9d95e65901e6f2ac/PyMySQL-0.8.0-py2.py3-none-any.whl Installing collected packages: PyMySQL Successfully installed PyMySQL-0.8.0Test that it work. Python 3.6.4 (default, Mar 15 2018, 15:35:10) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pymysql.cursors >>> # no errorThen is just to follow Example. RE: mysql db connection using python - sunstar20 - Apr-21-2018 I'm using python2.7 RE: mysql db connection using python - snippsat - Apr-21-2018 (Apr-21-2018, 05:45 PM)sunstar20 Wrote: I'm using python2.7Look at Requirements, so it work fine for 2.7. If want to use Python 3 as you should,look at Linux Python 3 environment. RE: mysql db connection using python - vishalhule - Aug-04-2018 I suggest you install 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 can install connector using pip or you can download DEB Package for MySQL Connector Python and install it. Use this link to install and verify the installation Install MySQL connector Python To verify installation you can import mysql.connector and check if the program gives an error if not your installation is complete. follow this article to connect to MySQL from python and execute database queries.Python MySQL connection |