วันอังคารที่ 27 มีนาคม พ.ศ. 2561

Week 8

What you have done/learned

  • ได้ทดสอบความเร็วในการ Insert/Query ข้อมูลจาก Python ไปยัง MySQL Workbench โดยข้อมูลที่ได้เกิดจากการสุ่มทั้งหมด

Problem/Solution

  • พบว่าการ Query ดูผลโดยการใช้ Select * นั้นส่งผลให้ตัวคอมพิวเตอร์ช้าเนื่องจากกินทรัพยากรมาก ทำการแก้ไขโดย Query แบบมีเงื่อนไข เพื่อลดปัญหาการนำข้อมูลที่ไม่ต้องการแสดงมาเกินความต้องการ
  • โปรแกรมเดียวกันไม่สามารถรันได้ในทุกๆเครื่องเนื่องจากใช้ Python คนละ Version แก้ไขโดยการตกลงกันในกลุ่มเพื่อหา Version ที่เหมาะสม

Decision

  • ได้ทำการเปลี่ยนโปรเจ็คจากคลินิกทำฟันเป็นนักวิ่งมาราธอนแทนเนื่องจากตัวงานมี scale ที่ใหญ่เกินไปทำให้วุ่นวายต่อการศึกษาพัฒนา
  • ได้ทดลองให้ Slack ในการคุยและแลกเปลี่ยนข่าวสารในการทำงานเนื่องจากตัว Slack มีการทำงานที่รองรับทั้ง Voice Chat, Third party Authentication รวมไปถึงสามารถทำ poll และสามารถปรับเปลี่ยนการนำเสนอของโค้ดได้ เช่น การเว้นวรรค ทำให้มองโค้ดได้ง่ายมากขึ้น

Related Info/Link/Reference

  • ตัวโค้ดที่ใช้ในการทำงาน
import MySQLdb
import sys
import datetime
import json
import random
import string
from random import randint

def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
    return ''.join(random.choice(chars) for _ in range(size))

grade_rand = ['A', 'B+', 'B', 'C+', 'C', 'D+', 'D', 'F']
json_file = {}

try:
    db = MySQLdb.connect(
        host = 'localhost',
        user = 's5830041',
        passwd = '4t44o0on',
        db = 'student'
    )
except Exception as e:
    sys.exit('Server Disconnected')

count = 0
cursor = db.cursor()
for i in range(int(3e3)) :
    print(i)
    for j in range(int(1e3)):
        for k in range(4):
            for l in range(10):
                json_file['100'+str(k)+'0'+str(l)] = random.choice(grade_rand)
        grade = json.dumps(json_file)

        try:
            cursor.execute("INSERT INTO student_data VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)""",
                           (str(int(i*1e3+j)).zfill(8), id_generator(randint(8, 126)), id_generator(randint(8, 126)),
                            id_generator(randint(127, 500)), id_generator(10,"0987654321"), id_generator(randint(12, 125)),
                            datetime.date(randint(1900, 2020), randint(1, 12), randint(1, 25)), str(randint(30, 150)),
                            str(randint(120, 230)), id_generator(randint(3, 40)), id_generator(randint(3, 40)), grade))
        except:
                print('lost')
                count += count
    db.commit()

ไม่มีความคิดเห็น:

แสดงความคิดเห็น

Database Project

ผลงานทั้งหมดจากกลุ่มที่ 3 ลิ้งวิดิโออธิบายส่วน ER-Diagram https://www.youtube.com/watch?v=N3VQIO56_kM ลิ้งวิดิโอส่วน web applica...