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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started