Answers for "issue mysql command through python"

SQL
0

issue mysql command through python

import mysql.connector as mysql

db = mysql.connect(
    host = "localhost",
    user = "root",
    passwd = "dbms",
    database = "datacamp"
)

cursor = db.cursor()

## defining the Query
query = "SELECT * FROM users"

## getting records from the table
cursor.execute(query)

## fetching all records from the 'cursor' object
records = cursor.fetchall()

## Showing the data
for record in records:
    print(record)
Posted by: Guest on July-20-2021

Code answers related to "issue mysql command through python"

Code answers related to "SQL"

Browse Popular Code Answers by Language