* ๋ฌธ์ ์กฐ๊ฑด.
1. ์ํ ํ
์ด๋ธ, ์ฃผ๋ฌธ ํ
์ด๋ธ์ ์์ฑ
2. ์ํ ํ
์ด๋ธ์ ์ํ๋ค์ ์ฝ์
ํ ๊ฒ
3. print์ input์ผ๋ก ์ฌ์ฉ์์๊ฒ ์ํ๋ฒํธ์ ์ฃผ๋ฌธ ์๋์ ์
๋ ฅ๋ฐ๊ธฐ.
4. ์
๋ ฅ๋ฐ์ ์ฃผ๋ฌธ์ ๋ณด๋ฅผ ์ฃผ๋ฌธ ํ
์ด๋ธ์ ์ ์ฅํ ๊ฒ.
5. db์ ์ ์ฅ๋ ์ฃผ๋ฌธ ํ
์ด๋ธ์ ๋ชฉ๋ก์ ์ถ๋ ฅํ ๊ฒ.
python
import sqlite3
connect = sqlite3.connect('al.sqlite', isolation_level=None)
c = connect.cursor()
color = ['red', 'blue']
size = ['S', 'M', 'L']
goods_code = ['T8081', 'T8082']
product_list = []
order_list = []
c.execute("CREATE TABLE order_list(id INTEGER PRIMARY KEY, num INTEGER, EA INTEGER)")
c.execute("CREATE TABLE product_list(id INTEGER PRIMARY KEY, goods_code TEXT)")
idx = 0
print("----์ํ ๋ชฉ๋ก----")
for code in goods_code:
for s in size:
for co in color:
product = code + ", ์ฌ์ด์ฆ : " + s + ", ์๊น : " + co
product_list.append(product)
idx += 1
c.execute("INSERT INTO product_list(id, goods_code) VALUES(?,?)",(idx, product))
print("%s๋ฒ : %s" %(idx, product))
idx = 0
while(True):
num = input("์ํ์ ๊ณ ๋ฅด์ธ์! ์ํ์ ํด๋นํ๋ ๋ฒํธ๋ฅผ ์
๋ ฅํ๋ฉด ๋ฉ๋๋ค.")
EA = input("์ฃผ๋ฌธํ ์๋์ ์
๋ ฅํ์ธ์.")
exitt = input("์ฃผ๋ฌธ์ด ๋๋ฌ์ผ๋ฉด 'x'๋ฅผ ์
๋ ฅํ์ธ์, ๊ณ์ํ์๋ ค๋ฉด ์ํฐ๋ฅผ ๋๋ฌ์ฃผ์ธ์.")
idx +=1
c.execute("INSERT INTO order_list(id, num, EA) VALUES(?,?,?)", (idx, num, EA))
order_list.append(num)
if exitt == "x":
break
for i,num in enumerate(order_list):
c.execute("SELECT * FROM product_list WHERE id = '%s'"%num)
op = c.fetchone()
c.execute("SELECT * FROM order_list WHERE id = '%s'"%(i+1))
oe = c.fetchone()
print("์ฃผ๋ฌธ ์ํ : %s, ์ฃผ๋ฌธ ์๋ :%s๊ฐ" %(op[1:] ,oe[2]))