- SQL INSERT INTO Statement
- The SQL CREATE TABLE Statement
- SQL UNIQUE Constraint
- SQL PRIMARY KEY Constraint
- SQL FOREIGN KEY Constraint
- download และ install mysql connector for python จาก https://dev.mysql.com/downloads/file/?id=472568
- เขียนโปรแกรมภาษา python รับข้อมูล ชื่อ นามสกุล และรหัสนักศึกษา เพื่อนำไปสร้างข้อมูล student ใน database
- เขียนโปรแกรมภาษา python เลือกไฟล์ csv เพื่อนำไป เพิ่มใน database
- เขียนโปรแกรมภาษา python เพื่อสร้าง database, table และ insert ข้อมูลลงใน database ที่สร้าง
- ในการใช้คำสั้ง input จำเป็นต้องกรอก input โดยมีเครื่องหมาย " " เช่น หากต้องการจะกรอกชื่อ จะต้องกรอกเป็น 'name' ไม่สามารถกรอก name เฉยๆได้ สร้างความลำบากในการใช้งาน แก้ไขโดยการเปลี่ยนไปใช้คำสั่ง raw_input แทน โดยศึกษาจาก Python 2.7 getting user input and manipulating as string without quotations
- ไม่สามารถ INSERT DATA ได้ เกิด error Not all parameters were used in MySQL statement สาเหตุเกินจาก การใส่ค่า VALUES ใน INSERT ต้องเป็น %S(String) เท่านั้น จึงทำการเปลี่ยน format ทุก attributes ให้เป็น %S ทั้งหมด จากบางอันที่เป็น %I
- ให้ primary key ของ TABLE Students เป็น Student_id หรือ รหัสนักศึกษาเนื่องจากไม่สามารถซ้ำกันได้
- กำหนด attribute ชื่อ pk ใน TABLE Student_record เพื่อ เป็น primary key ของ TABLE นี้ เนื่องจาก attribute อื่นๆ ทุกตัวสามารถซ้ำกันได้
related info/link/reference:
- github (week 3 code)
- mysql-connector-python-2.1.7-py2.7
- How to connect Python programs to MariaDB
- Application Programming Interfaces
- Choosing a file in Python with simple Dialog
- Tkinter tkFileDialog module
- Python 2.7 getting user input and manipulating as string without quotations
- Chapter 5 Connector/Python Coding Examples