Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Connect to MySQL Using Connector Python C Extension

import mysql.connector
from mysql.connector import Error
try:
    connection = mysql.connector.connect(host='localhost',
                                         database='techshop',
                                         user='root',
                                         password='', use_pure=True)
    if connection.is_connected():
        db_Info = connection.get_server_info()
        print("Connected to MySQL database... MySQL Server version on ", db_Info)
except Error as e:
    print("Error while connecting to MySQL", e)
finally:
    if connection.is_connected():
        connection.close()
        print("MySQL connection is closed")
Comment

PREVIOUS NEXT
Code Example
Python :: entry tkinter 
Python :: Average of total in django querysets 
Python :: how to find number of categories in python 
Python :: how to access app.config globally in flask app 
Python :: pandas append new column 
Python :: python parse /etc/resolv.conf 
Python :: /n python 
Python :: how to get max value and min values in entire dataframe 
Python :: flask or django 
Python :: plotly dash datatable column width 
Python :: how to sort dataframe in python by length of groups 
Python :: join on index python 
Python :: crawling emails with python 
Python :: python sort() and sorted() 
Python :: confusion matrix code 
Python :: pyqt popup yes no 
Python :: Python NumPy ascontiguousarray Function Example Scalar to an array 
Python :: objects and classes in python 
Python :: get every second elemnt of array matlab 
Python :: python word encode asci 
Python :: python dataframe add row 
Python :: histogram relative frequency 
Python :: webex teams api attach file 
Python :: lru cache 
Python :: python sort list by rule 
Python :: python function 
Python :: 151 - Power Crisis solution in python 
Python :: http404 django 
Python :: Using Python Permutations to Find the order in lexicographical sorted order 
Python :: How split() works in Python? 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =