Answers for "python MySQL library"

14

python install mysql connector

pip3 install mysql-connector-python  #Python 3
pip install mysql-connector-python
Posted by: Guest on June-09-2020
5

python mysql connector

# real nice guide, as well as instalation guide: https://pynative.com/python-mysql-database-connection/
# pip install mysql-connector-python
import mysql.connector
from mysql.connector import Error

try:
    connection = mysql.connector.connect(host='localhost',
                                         database='Electronics',
                                         user='pynative',
                                         password='pynative@#29')
    if connection.is_connected():
        db_Info = connection.get_server_info()
        print("Connected to MySQL Server version ", db_Info)
        cursor = connection.cursor()
        cursor.execute("select database();")
        record = cursor.fetchone()
        print("You're connected to database: ", record)

except Error as e:
    print("Error while connecting to MySQL", e)
finally:
    if (connection.is_connected()):
        cursor.close()
        connection.close()
        print("MySQL connection is closed")
Posted by: Guest on April-07-2020
4

how to connect to mysql database in python

import mysql.connector

cnx = mysql.connector.connect(user='scott', password='password',
                              host='127.0.0.1',
                              database='employees')
cnx.close()
Posted by: Guest on March-23-2020
5

connect python to mysql

import mysql.connector
mydb = mysql.connector.connect(
  host="localhost",
  user="yourusername",
  password="yourpassword",
  port = 8888, #for Mamp users
  database='whatever db you want'
)
print(mydb)
Posted by: Guest on June-01-2020
3

mysql python connector

import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="yourusername",
  password="yourpassword"
)

print(mydb)
Posted by: Guest on July-04-2020
3

python mysql

C:UsersYour NameAppDataLocalProgramsPythonPython36-32Scripts>python -m pip install 
  mysql-connector-python
Posted by: Guest on May-18-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language