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.0218 sec