Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

mysql connector select

import mysql.connector

db = mysql.connector.connect(option_files='my.conf', use_pure=True)

cursor = db.cursor()

sql = """
select * from town limit 5
"""

try:
    cursor.execute(sql)

    for row in cursor:
        print(row)


    cursor.close()
    db.close()

except mysql.connector.ProgrammingError as err:
    print(err.errno)
    print(err.sqlstate)
    print(err.msg)

except mysql.connector.Error as err:
    print(err)
Comment

PREVIOUS NEXT
Code Example
Python :: matplotlib facet scatter 
Python :: Python Basic View 
Python :: python threadpool map exception 
Python :: ENCAPSUALTION 
Python :: set focus in last position entry tkinter 
Python :: find downold dir in python 
Python :: json file download 
Python :: how to check columns with the numerical values 
Python :: Python Tkinter Scale Widget Syntax 
Python :: Using pushbullet to export whatsapp chat 
Python :: short hand function pytho 
Python :: python Detect Cycle in a Directed Graph 
Python :: get out of a help screen python 
Python :: Joining String And Variable 
Python :: flask-sqlalchemy inheritance 
Python :: print anything in python 
Python :: pyhton transpose without changing column and row names 
Python :: python http server onliner 
Python :: python how to tell if class is initialized 
Python :: why do we need to preprocess data 
Python :: python file operation 
Python :: jax.numpy 
Python :: india states django choices 
Python :: python print statements 
Python :: choose a random snippet of text 
Python :: make a copy for parsing dataframe python 
Python :: wxPython wx.Window Connect example 
Python :: pyqt message box set detailed text 
Python :: print class name python 
Python :: Python Module Search Path 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =