構(gòu)建智慧校園平臺的技術(shù)實(shí)踐與對話
CREATE TABLE students (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
age INT,
gender ENUM('M', 'F'),
major VARCHAR(100)
);
]]>
import mysql.connector
conn = mysql.connector.connect(
host='localhost',
user='root',
password='yourpassword',
database='school'
)
cursor = conn.cursor()
sql = "INSERT INTO students (name, age, gender, major) VALUES (%s, %s, %s, %s)"
val = ("Alice", 20, "F", "Computer Science")
cursor.execute(sql, val)
conn.commit()
print(cursor.rowcount, "record inserted.")
]]>
def authenticate(username, password):
# 假設(shè)已連接到數(shù)據(jù)庫conn
cursor = conn.cursor(dictionary=True)
cursor.execute("SELECT * FROM users WHERE username=%s AND password=%s", (username, password))
result = cursor.fetchone()
return True if result else False
]]>
本站知識庫部分內(nèi)容及素材來源于互聯(lián)網(wǎng),如有侵權(quán),聯(lián)系必刪!
讀過這篇文章的讀者還喜歡:
智慧校園系統(tǒng)與大模型的碰撞數(shù)字校園網(wǎng)頁版的實(shí)現(xiàn)與代碼解析數(shù)字校園遇上職校,笑談未來教育新篇章南昌智慧校園系統(tǒng)上線,我狂喜不已智慧校園平臺在高校中的技術(shù)實(shí)現(xiàn)與應(yīng)用智慧校園與人工智能體的幸福融合智慧校園系統(tǒng)在理工大學(xué)中的應(yīng)用與實(shí)現(xiàn)智慧校園與AI助手的技術(shù)融合與發(fā)展智慧校園與理工大學(xué)的技術(shù)融合智慧校園建設(shè)在師范大學(xué)中的應(yīng)用與技術(shù)實(shí)現(xiàn)