U E D R , A S I H C RSS

Python/Data Base


1.1. μ‚¬μš©λ²•

  • μ•„λž˜ μ†ŒμŠ€λŠ” 파이썬 DB API Spec 2.0 에 μžˆλŠ” 것듀을 μ‚¬μš©ν•΄μ„œ μž‘μ„±ν•¨(즉 λ‹€λ₯Έ λͺ¨λ“ˆμ—μ„œλ„ λ™μΌν•˜κ²Œ μ‚¬μš©κ°€λŠ₯)
  • connect 에
host - hostname (NULL : default)
user - username (NULL)
passwd - password (no password)
db - database name (NULL)
port - integer, TCP/IP port
unix_socket - TCPλ₯Ό μ‚¬μš©ν•  unixμ†ŒμΌ“μ˜ μœ„μΉ˜
client_flag - integer, ν•„μš”ν•  경우 μ‚¬μš©ν•˜κΈ° μœ„ν•œ flag (0)
을 인자둜 넣을 수 μžˆλ‹€.
~cpp
import MySQLdb
con =MySQLdb.connect(user="name", passwd="password", db="databasename")
cur = con.cursor()
cur.execute("select * from owiki_page_name")
print cur.description
print cur.rowcount
res = cur.fetchone()
res = cur.fetchall()
res = cur.fetchmany(10)
print res[x][x]
cur.close()

1.2. μ°Έκ³ 

zeropage μ—μ„œ νŒŒμ΄μ„  곡뢀할 μ‚¬λžŒμ€ ν•„μš”ν•œ λͺ¨λ“ˆμžˆμœΌλ©΄ κ²Œμ‹œνŒμ— 올리기 λ°”λžŒ. - eternalbleu
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:24:09
Processing time 0.0133 sec