Question: Hello Need a help with the syntax, printing the check number Database to download from packages to download. python-3.7.7-amd64.exe mysql-connector-python-8.0.19-windows-x86-64bit mysql 8.0.19 import mysql.connector local_db

Hello

Need a help with the syntax, printing the check number

Database to download from

packages to download.

python-3.7.7-amd64.exe

mysql-connector-python-8.0.19-windows-x86-64bit

mysql 8.0.19

import mysql.connector

local_db = mysql.connector.connect(user='root', password='admin',

host='127.0.0.1',

database='classicmodels')

#==================================================================================================================

#3. Python script

local_db_cursor = local_db.cursor()

local_db_cursor.execute(

"select customerNumber,amount,checkNumber,paymentDate from payments where month(paymentDate) = 12;" )

db_res = local_db_cursor.fetchall()

print("Payment before rebate.. " + "-" * 45)

print("{: <15} {: <15} {: <15}".format("CustomerID", "paymentDate", "Amount", "checkNumber"))

for x in db_res:

print("{: <15} {: <15} {: <15}".format(x[0], str(x[2]), x[1]))

print("Payment after rebate.. " + "-" * 45)

print("{: <15} {: <15} {: <15}".format("CustomerID", "PaymentDate", "Amount", "checkNumber"))

for x in db_res:

amt = float(x[1])

amt = amt - (amt / 100.0)

print("{: <15} {: <15} {: <15.2f}".format(x[0], str(x[2]), amt))

#4. JOIN

print(" " + "-" * 50)

query = "select customerName,p.paymentDate from customersinner join payments p onmonth(p.paymentDate) = 12 limit 30;"

local_db_cursor.execute(query)

print("{: <30} {: <30}".format("CustomerName", "PaymentDate", "checkNumber"))

for x in local_db_cursor.fetchall():

print("{: <30} {: <30}".format(x[0], str(x[1])))

-T

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!