๐ RDB
๋ฐ์ดํฐ๋ฒ ์ด์ค(DataBase)์ ์ข ๋ฅ๋ ํฌ๊ฒ 1. ๊ด๊ณํ ๋ฐ์ดํฐ๋ฒ ์ด์ค(RDB, 2. NoSQL(Not Only SQL)๋ก ๋๋๋ค.
RDB(Relation Database)๋ ๊ด๊ณํ ๋ฐ์ดํฐ ๋ชจ๋ธ์ ๊ธฐ๋ฐ์ผ๋ก ํ ๋ฐ์ดํฐ ๋ฒ ์ด์ค๋ค.
๋ค์ ๋งํด, ํค(Key) - ๊ฐ(Value)๋ค์ ๊ฐ๋จํ ๊ด๊ณ๋ฅผ ํ
์ด๋ธํํ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ค. RDB๋ ๋ค์ ํน์ง์ ๊ฐ์ง๋ค.
- ๋ฐ์ดํฐ ๋ ๋ฆฝ์ฑ์ด ๋๋ค.
- ๊ณ ์์ค์ DML์ ์ฌ์ฉํด์, ๊ฒฐํฉ, ์ ์, ํฌ์ ๋ฑ์ ๊ด๊ณ ์กฐ์์ ์ํด ๋น์ฝ์ ์ผ๋ก ํํ ๋ฅ๋ ฅ์ ๋์ผ ์ ์๋ค.
- ์ด๋ค์ ๊ด๊ณ ์กฐ์์ ์ํด ์์ ๋กญ๊ฒ ๊ตฌ์กฐ๋ฅผ ๋ณ๊ฒฝํ ์ ์๋ค.
๐ก RDB์ ์ข ๋ฅ
- Oracle
- MySQL
- MS-SQL
- DB2
- Maria DB
- Derby
- SQLite
๐ RDB์ Flask์ ์ํธ์์ฉ
Flask์์ RDB๋ฅผ ์ฐ๋ํ๋ฉด ์ด๋ป๊ฒ ๋ ๊น ? Flask์์ ์ ๋ ฅ ๋ฐ์ ๋ด์ฉ๋ค์ DB์ ์ ์ฅํ ์ ์์ด์ผ ํ๋ค.
= ํจ์จ์ ์ธ ๋ฐ์ดํฐ ๊ด๋ฆฌ ๊ธฐ๋ฅ ์ ๊ณต
ํ์ด์ฌ์ ์คํ ์์ค์ ์์ฉ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ๋ํ ๋๋ถ๋ถ์ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์์ง์ ์ํ ํจํค์ง๋ฅผ ๊ฐ์ง๊ณ ์๋ค.
์์ผ๋ก์ ํฌ์คํ
์์๋ ๊ทธ ์ค, sqlite3 ์ Flask ์ดํ๋ฆฌ์ผ์ด์
์์ ์๋ SQLAlchemy๋ฅผ ์ฌ์ฉํด์ ์งํํ๋ค.
SQLAlchemy๋ ํ์ด์ฌ ์ฝ๋์ DB์ ์ฐ๊ฒฐํ๊ธฐ ์ํด ์ฌ์ฉ๋๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค.
๐ Flask - RDB ์์ : ๊ฒ์ํ ๊ตฌํํ๊ธฐ
๐ก DB ์ฌ์ฉ์ ์ถ๊ฐ
from flask import Flask, render_template, request, url_for, redirect
import sqlite3 # salite3
app = Flask(__name__)
conn = sqlite3.connect("database.db") # splite3 db ์ฐ๊ฒฐ
print("Opened database successfully")
conn.execute("CREATE TABLE IF NOT EXISTS Board(name TEXT, context TEXT)") # Board ๋ผ๋ DB์์ฑ
print("TABLE Created Successfully")
name = [
["Elice", 15],
["Dodo", 16],
["checher", 17],
["Queen", 18]
]
for i in range(len(name)):
conn.execute(f"INSERT INTO Board(name,context) VALUES('{name[i][0]}', '{name[i][1]}')") # Board DB์ ๋ฐ์ดํฐ ์ฝ์
conn.commit() # ์ง๊ธ๊ป ์์ฑํ SQL, DB์ ๋ฐ์ commit
conn.close() # ์์ฑ ๋คํ DB๋ ๋ซ์์ค์ผํจ close
# ================= ์ฌ๊ธฐ์๋ถํฐ๋ ๋ค์ Flask ์์ญ ==========================
@app.route('/')
def board():
con = sqlite3.connect("database.db")
cur = con.cursor()
cur.execute("SELECT * FROM Board")
rows = cur.fetchall()
print("DB: ")
for i in range(len(rows)):
print(rows[i][0] + ':' + rows[i][1])
return render_template("board1.html", rows = rows)
@app.route("/search", methods=["GET","POST"])
def search():
if request.method == "POST":
name = request.form["name"] # search.html ๊ฐ๋ณด๋ฉด, form์ name๋ง ๋ฐ๊ธฐ๋ก ํจ.
con = sqlite3.connect("database.db")
cur = con.cursor()
cur.execute(f"SELECT * FROM Board WHERE name='{name}'")
rows = cur.fetchall()
print("DB : ")
for i in range(len(rows)):
print(rows[i][0] + ':' + rows[i][1])
return render_template("search.html", rows=rows)
else:
return render_template("search.html")
@app.route("/add", methods=["GET","POST"])
def add():
if request.method == "POST":
try:
name = request.form["name"]
context = request.form["context"]
# DB์ ์ ๊ทผํด์, ๋ฐ์ดํฐ๋ฅผ ์ฝ์
ํ ๋๋, ์ง์ DB๋ฅผ ์ด์ด์ผ๋๋๋ฐ, ์ ๊ณผ์ ์ฒ๋ผ, close๊น์ง ํ๊ธฐ ํ๋๋๊น, ํ๋ ๋ฐฉ์, ๊ฒฐ๊ณผ๋ ๊ฐ์ ๊ฒ !
with sqlite3.connect("database.db") as con:
cur = con.cursor()
cur.execute(f"INSERT INTO Board(name,context) VALUES('{name}','{context}')")
con.commit()
except:
con.rollback() # DB ๋กค๋ฐฑํจ์, SQL์ด ์ค๋ฅ๋๋ฉด, ๋ฐ์์ , ์ด์ ์ํ๋ก ๋๋ฆฌ๋ ๊ฒ
finally:
return redirect(url_for("board"))
else:
return render_template("add.html")
if __name__ == '__main__':
app.run()
<!-- ./templates/board1.html -->
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>SQLite3 ๊ฒ์ํ ๋ฑ๋ก</title>
<style type="text/css">
body {
text-align: center;
}
</style>
</head>
<body>
<h3>๊ฒ์ํ</h3>
<h4><a href="{{url_for('add')}}">์ถ๊ฐ</a> <a href="{{url_for('search')}}">๊ฒ์</a><br><br>๋ชฉ๋ก</h4>
<table border=1 width="600" align="center">
<thead>
<td>์ด๋ฆ</td>
<td>๋ด์ฉ</td>
</thead>
{% for row in rows %}
<tr>
<td>{{ row[0] }}</td>
<td>{{ row[1] }}</td>
</tr>
{% endfor %}
</table>
</body>
</html>
<!-- ./templates/add.html -->
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>SQLite3 ๊ฒ์ํ ๋ฑ๋ก</title>
<style type="text/css">
body {
text-align: center;
}
</style>
</head>
<body>
<h3>๊ฒ์ํ</h3>
<h4>์ถ๊ฐ</h4>
<form action="/add" method="POST">
์ด๋ฆ<br>
<input type="text" name="name" /><br>
๋ด์ฉ<br>
<input type="text" name="context" style="text-align:center; width:400px; height:100px;" /><br><br>
<input type="submit" value="๊ฒ ์" /><br>
</form>
</body>
</html>
<!-- ./templates/search.html -->
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>SQLite3 ๊ฒ์ํ ๋ฑ๋ก</title>
<style type="text/css">
body {
text-align: center;
}
</style>
</head>
<body>
<form action="/search" method="POST">
<input type="text" name="name" />
<input type="submit" value="๊ฒ ์" /><br>
</form>
<h4>๊ฒ์๊ฒฐ๊ณผ</h4>
{% if rows%}
<table border=1 width="600" align="center">
<thead>
<td>์ด๋ฆ</td>
<td>๋ด์ฉ</td>
</thead>
{% for row in rows %}
<tr>
<td>{{ row[0] }}</td>
<td>{{ row[1] }}</td>
</tr>
{% endfor %}
{% else %}
<p> ๊ฒ์๊ฒฐ๊ณผ๊ฐ ์์ต๋๋ค. </p>
{% endif %}
</table>
</body>
</html>
๐ก ์ค๋ณต ์ฌ์ฉ์ ์ ์ด ( ์์, DB ์ฌ์ฉ์ ์ถ๊ฐ์์ ๋ณํ ์ฝ๋๋ ๋ช ์์
from flask import Flask, render_template, request, url_for, redirect
import sqlite3 # salite3
app = Flask(__name__)
conn = sqlite3.connect("database.db") # splite3 db ์ฐ๊ฒฐ
print("Opened database successfully")
conn.execute("CREATE TABLE IF NOT EXISTS Board(name TEXT, context TEXT)") # Board ๋ผ๋ DB์์ฑ
print("TABLE Created Successfully")
name = [
["Elice", 15],
["Dodo", 16],
["checher", 17],
["Queen", 18]
]
for i in range(len(name)):
conn.execute(f"INSERT INTO Board(name,context) VALUES('{name[i][0]}', '{name[i][1]}')") # Board DB์ ๋ฐ์ดํฐ ์ฝ์
conn.commit() # ์ง๊ธ๊ป ์์ฑํ SQL, DB์ ๋ฐ์ commit
conn.close() # ์์ฑ ๋คํ DB๋ ๋ซ์์ค์ผํจ close
# ================= ์ฌ๊ธฐ์๋ถํฐ๋ ๋ค์ Flask ์์ญ ==========================
@app.route('/')
def board():
con = sqlite3.connect("database.db")
cur = con.cursor()
cur.execute("SELECT * FROM Board")
rows = cur.fetchall()
print("DB: ")
for i in range(len(rows)):
print(rows[i][0] + ':' + rows[i][1])
return render_template("board1.html", rows = rows)
@app.route("/search", methods=["GET","POST"])
def search():
if request.method == "POST":
name = request.form["name"] # search.html ๊ฐ๋ณด๋ฉด, form์ name๋ง ๋ฐ๊ธฐ๋ก ํจ.
con = sqlite3.connect("database.db")
cur = con.cursor()
cur.execute(f"SELECT * FROM Board WHERE name='{name}'")
rows = cur.fetchall()
print("DB : ")
for i in range(len(rows)):
print(rows[i][0] + ':' + rows[i][1])
return render_template("search.html", rows=rows)
else:
return render_template("search.html", msg ="๊ฒ์์ด๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.")
@app.route("/add", methods=["GET","POST"])
def add():
if request.method == "POST":
name = request.form["name"]
context = request.form["context"]
# DB์ ์ ๊ทผํด์, ๋ฐ์ดํฐ๋ฅผ ์ฝ์
ํ ๋๋, ์ง์ DB๋ฅผ ์ด์ด์ผ๋๋๋ฐ, ์ ๊ณผ์ ์ฒ๋ผ, close๊น์ง ํ๊ธฐ ํ๋๋๊น, ํ๋ ๋ฐฉ์, ๊ฒฐ๊ณผ๋ ๊ฐ์ ๊ฒ !
with sqlite3.connect("database.db") as con:
cur = con.cursor()
cur.execute(f"SELECT count(*) FROM Board WHERE name='{name}'")
# ํ์ ํ๋ช
, ์ถ๊ฐํ ๋ผ ํ๋๋ฐ, ๊ทธ์ ์ ๋ค์ด์จ, name๊ฐ์ด๋ ๊ฐ์ ์ด๋ฆ์ด DB์ ์์ผ๋ฉด, ์ค๋ณตํ์์์ด๋ฏ๋ก, ๋ชปํ๊ฒ ์ ์ดํจ
if cur.fetchall()[0][0] == 0: # ์ค๋ณต์ด๋ฆ์ด ์์ผ๋ฉด
cur.execute(f"INSERT INTO Board(name,context) VALUES('{name}','{context}')")
con.commit()
cur.execute("SELECT * FROM Board")
rows = cur.fetchall()
return render_template("board1.html",rows= rows)
else: # ์ค๋ณต์ด๋ฆ์ด ์์ผ๋ฉด
return render_template("add.html",msg = "์ค๋ณต์ฌ์ฉ์๊ฐ ์์ต๋๋ค.")
else:
return render_template("add.html")
if __name__ == '__main__':
app.run()
<!-- ./templates/board1.html -->
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>SQLite3 ๊ฒ์ํ ๋ฑ๋ก</title>
<style type="text/css">
body {
text-align: center;
}
</style>
</head>
<body>
<h3>๊ฒ์ํ</h3>
<h4><a href="{{url_for('add')}}">์ถ๊ฐ</a> <a href="{{url_for('search')}}">๊ฒ์</a><br><br>๋ชฉ๋ก</h4>
<table border=1 width="600" align="center">
<thead>
<td>์ด๋ฆ</td>
<td>๋ด์ฉ</td>
</thead>
{% for row in rows %}
<tr>
<td>{{ row[0] }}</td>
<td>{{ row[1] }}</td>
</tr>
{% endfor %}
</table>
</body>
</html>
<!-- ./templates/add.html -->
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>SQLite3 ๊ฒ์ํ ๋ฑ๋ก</title>
<style type="text/css">
body {
text-align: center;
}
</style>
</head>
<body>
<h3>๊ฒ์ํ</h3>
<h4>์ถ๊ฐ</h4>
<form action="/add" method="POST">
์ด๋ฆ<br>
<input type="text" name="name" /><br>
๋ด์ฉ<br>
<input type="text" name="context" style="text-align:center; width:400px; height:100px;" /><br><br>
<input type="submit" value="๊ฒ ์" /><br>
</form>
{% if msg %}
<p> {{ msg }} </p>
{% endif %}
</body>
</html>
<!-- ./templates/reaserch.html -->
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>SQLite3 ๊ฒ์ํ ๋ฑ๋ก</title>
<style type="text/css">
body {
text-align: center;
}
</style>
</head>
<body>
<form action="/search" method="POST">
<input type="text" name="name" />
<input type="submit" value="๊ฒ ์" /><br>
</form>
<h4>๊ฒ์๊ฒฐ๊ณผ</h4>
{% if rows%}
<table border=1 width="600" align="center">
<thead>
<td>์ด๋ฆ</td>
<td>๋ด์ฉ</td>
</thead>
{% for row in rows %}
<tr>
<td>{{ row[0] }}</td>
<td>{{ row[1] }}</td>
</tr>
{% endfor %}
{% elif msg %}
<p> {{ msg }} </p>
{% else %}
<p> ๊ฒ์๊ฒฐ๊ณผ๊ฐ ์์ต๋๋ค. </p>
{% endif %}
</table>
</body>
</html>
๐ก ๊ฒ์ํ ๋ด์ฉ ์์ฑ ๋ฐ ์กฐํ
์์์, DB ์ฌ์ฉ์ ์์ฑ, ์ค๋ณต์ ๊ฑฐ ๋ด์ฉ๊ณผ ๋์ผ
๐ก ๊ฒ์ํ ๋ด์ฉ ์์ ๋ฐ ์ญ์
#DATABASE
from flask import Flask, render_template, request, url_for, redirect
import sqlite3
app = Flask(__name__)
conn = sqlite3.connect('database.db')
print ("Opened database successfully")
conn.execute("DROP TABLE IF EXISTS Board") # Board ํ
์ด๋ธ์ด ๊ธฐ์กด์ ์๋ค๋ฉด ์ญ์ (๋งค๋ฒ, ๋์ผํ ํ์ผ์์ ์คํํ๋ฉด, ๋ด์ฉ์ด ๊ฒน์ณ์ ๋ง๋ฆ)
conn.execute('CREATE TABLE IF NOT EXISTS Board (name TEXT, context TEXT)') # Board ํ
์ด๋ธ์ด ๊ธฐ์กด์ ์๋ค๋ฉด ์์ฑ
print ("Table created successfully")
name = [['Elice', 15], ['Dodo', 16], ['Checher', 17], ['Queen', 18]]
for i in range(4):
conn.execute(f"INSERT INTO Board(name, context) VALUES('{name[i][0]}', '{name[i][1]}')")
conn.commit()
conn.close()
# root = home
@app.route('/')
def board():
con = sqlite3.connect("database.db")
cur = con.cursor()
cur.execute("select * from Board")
rows = cur.fetchall()
print("DB:")
for i in range(len(rows)):
print(rows[i][0] + ':' + rows[i][1])
return render_template('board1.html', rows = rows)
# ๊ฒ์๋ฌผ ์กฐํ (Read)
@app.route('/search', methods = ['GET', 'POST'])
def search():
if request.method == 'POST':
name = request.form['name']
con = sqlite3.connect("database.db")
cur = con.cursor()
cur.execute(f"SELECT * FROM Board WHERE name='{name}' or context='{name}'")
rows = cur.fetchall()
print("DB:")
for i in range(len(rows)):
print(rows[i][0] + ':' + rows[i][1])
return render_template('search.html', rows = rows)
else:
return render_template('search.html')
# ๊ฒ์๋ฌผ ์์ฑ (Create)
@app.route('/add', methods = ['GET', 'POST'])
def add():
if request.method == 'POST':
try:
name = request.form['name']
context = request.form['context']
with sqlite3.connect("database.db") as con:
cur = con.cursor()
cur.execute(f"INSERT INTO Board (name, context) VALUES ('{name}', '{context}')")
con.commit()
except:
con.rollback()
finally :
con.close()
return redirect(url_for('board'))
else:
return render_template('add.html')
# ์์ ์กฐํ, ์์ฑ์ ์ด์ ๊ณผ ๋์ผ
# ๊ฒ์๋ฌผ ๋ด์ฉ ๊ฐฑ์ (Update)
@app.route("/update/<uid>", methods=["GET","POST"])
def update(uid):
if request.method == "POST":
name = request.form["name"]
context = request.form["context"]
# ๋ด์ฉ ๊ฐฑ์ ํ๊ณ
with sqlite3.connect("database.db") as con:
cur = con.cursor() # connectionํ db์ ์ ๊ทผํ๊ธฐ ์ํด, cursor ๊ฐ์ฒด ๋ง๋ค๊ธฐ
cur.execute(f"UPDATE Board SET name='{name}', context='{context}' WHERE name='{uid}'")
con.commit()
return redirect(url_for("board")) # ๊ฐฑ์ ๋์๋์ง, boardํจ์ ๋ฆฌ๋ค์ด๋ ํธํด์, / ํ์ด์ง ๋ ๋๋ง
else:
con = sqlite3.connect("database.db")
cur = con.cursor()
cur.execute(f"SELECT * FROM Board WHERE name='{uid}'")
row = cur.fetchall()
return render_template("update.html",row=row)
@app.route("/delete/<uid>")
def delete(uid):
# ๋ค์ด์จ uid ๊ฐ์ด๋ name์ด๋ delete ์ฐ์ฐํ๊ณ ๋ฐ์
with sqlite3.connect("database.db") as con:
cur = con.cursor()
cur.execute(f"DELETE FROM Board WHERE name='{uid}'")
con.commit()
return redirect(url_for('board')) # ์ญ์ ๋ฐ์ํ๊ณ , ๋ฐ์๋ฌ๋์ง, boardํจ์ ๋ฆฌ๋ค์ด๋ ํธ, / ํ์ด์ง ๋ ๋๋ง
if __name__ == '__main__':
app.run()
<!-- ./templates/board1.html -->
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>SQLite3 ๊ฒ์ํ ๋ฑ๋ก</title>
<style type="text/css">
body {
text-align: center;
}
</style>
</head>
<body>
<h3>๊ฒ์ํ</h3>
<h4><a href="{{url_for('add')}}">์ถ๊ฐ</a> <a href="{{url_for('search')}}">๊ฒ์</a><br><br>๋ชฉ๋ก</h4>
<table border=1 width="600" align="center">
<thead>
<td>์ด๋ฆ</td>
<td>๋ด์ฉ</td>
<td>์์ /์ญ์ </td>
</thead>
{% for row in rows %}
<tr>
<td>{{ row[0] }}</td>
<td>{{ row[1] }}</td>
<td><a href="{{url_for('update', uid = row[0])}}">์์ </a> <a
href="{{url_for('delete', uid = row[0])}}">์ญ์ </a></td>
</tr>
{% endfor %}
</table>
</body>
</html>
<!-- ./templates/add.html -->
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>SQLite3 ๊ฒ์ํ ๋ฑ๋ก</title>
<style type="text/css">
body {
text-align: center;
}
</style>
</head>
<body>
<h3>๊ฒ์ํ</h3>
<h4>์ถ๊ฐ</h4>
<form action="/add" method="POST">
์ด๋ฆ<br>
<input type="text" name="name" /><br>
๋ด์ฉ<br>
<input type="text" name="context" style="text-align:center; width:400px; height:100px;" /><br><br>
<input type="submit" value="๊ฒ ์" /><br>
</form>
</body>
</html>
<!-- ./templates/research.html -->
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>SQLite3 ๊ฒ์ํ ๋ฑ๋ก</title>
<style type="text/css">
body {
text-align: center;
}
</style>
</head>
<body>
<form action="/search" method="POST">
<input type="text" name="name" />
<input type="submit" value="๊ฒ ์" /><br>
</form>
<h4>๊ฒ์๊ฒฐ๊ณผ</h4>
{% if rows%}
<table border=1 width="600" align="center">
<thead>
<td>์ด๋ฆ</td>
<td>๋ด์ฉ</td>
</thead>
{% for row in rows %}
<tr>
<td>{{ row[0] }}</td>
<td>{{ row[1] }}</td>
</tr>
{% endfor %}
{% else %}
<p> ๊ฒ์๊ฒฐ๊ณผ๊ฐ ์์ต๋๋ค. </p>
{% endif %}
</table>
</body>
</html>
<!-- ./templates/update.html -->
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>SQLite3 ๊ฒ์ํ ๋ฑ๋ก</title>
<style type="text/css">
body {
text-align: center;
}
</style>
</head>
<body>
<h3>๊ฒ์ํ</h3>
<h4>์์ </h4>
<form action="" method="POST">
์ด๋ฆ<br>
<input type="text" name="name" /><br>
๋ด์ฉ<br>
<input type="text" name="context" style="text-align:center; width:400px; height:100px;" /><br><br>
<input type="submit" value="์ ์ " /><br>
</form>
<h4>๊ธฐ์กด</h4>
<table border=1 width="600" align="center">
<thead>
<td>์ด๋ฆ</td>
<td>๋ด์ฉ</td>
</thead>
<tr>
<td>{{ row[0][0] }}</td>
<td>{{ row[0][1] }}</td>
</tr>
</table>
</body>
</html>
'python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Flask] (7) REST API (0) | 2021.01.28 |
---|---|
[Flask] (6) ORM & SQLAlchemy (0) | 2021.01.28 |
[Flask] (4) ์ธ์ฆ & ๋ก๊ทธ์ธ๊ตฌํ & ๋ก๊น (0) | 2021.01.25 |
[Flask] (3) ๋ ๋๋ง ํ ํ๋ฆฟ & Jinja2 & ๊ฐ๋จํ ๊ฒ์ํ (0) | 2021.01.24 |
[Flask] (2) REST & HTTP Method & API/End Point (0) | 2021.01.22 |