Python MySQL project

https://mrszeto.net/cprogram/Python-MySQL-project.htm

1. 下載、安裝 download & install Thonny Python to C:\Thonny\
	thonny.org
	Thonny for windows (exe)

2. 複製程式庫到 copy MySQLdb to C:\Thonny\Lib\site-packages\MySQLdb\
	MySQLdb.zip
xAmpp 3. MySQL 資料表 table: student student.txt 4. 測試程式 Try this program mysqldb-student.py 5. date.py


#-------------------------------------------------
from datetime import date, datetime, timedelta

#-------------------------------------------------
def dow(yy,mm,dd):
    dt = date(yy,mm,dd)
    return int(dt.strftime('%w'))

print('dow: ', dow(2023,12,3))

#-------------------------------------------------
now = date.today()
print("Today is ", now)    # now.year, now.month, now.day

due = now + timedelta(days=14)
print("today + 14 days: ", due)

day1 = date(now.year, 9, 1)
print((day1-now).days, " days")

#-------------------------------------------------
from colorama import Fore, Back, Style
# Fore: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
# Back: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
# Style: DIM, NORMAL, BRIGHT, RESET_ALL
print(Fore.RED + 'some red text')
print('-'*20)
print(Fore.GREEN   + 'some GREEN text')
print(Fore.YELLOW  + 'some YELLOW text')
print(Fore.BLUE    + 'some BLUE text')
print(Fore.MAGENTA + 'some MAGENTA text')
print(Fore.CYAN    + 'some CYAN text')
print(Fore.WHITE+Back.GREEN + 'and with a green background')
print(Style.DIM    + 'and in dim text')
print(Style.BRIGHT + 'and in BRIGHT text')
print(Style.RESET_ALL)
print('back to normal now')

#-------------------------------------------------
Q - 離開 Quit
I - 增新 Insert
D - 刪除 Delete
U - 更新 Update
L - 列出 List
R - 報告 Report
選擇 option (Q/I/D/U/L/R): ___

#-------------------------------------------------
MYSQL:	curdate() = today
	datediff(x,y) = date difference
SELECT curdate(), bor_date, due_date, datediff(due_date, bor_date) FROM loan