python mysql 접속 테스트 > 소스코드

본문 바로가기

회원로그인

회원가입

소스코드

python python mysql 접속 테스트

페이지 정보

profile_image
작성자 최고관리자
댓글 0건 조회 76회 작성일 22-11-23 13:37

본문

import pymysql

dbcon = pymysql.connect(host='localhost', user='root', password='lovesuk', db='control_box')
#curs = dbcon.cursor()      # 배열형태
curs = dbcon.cursor(pymysql.cursors.DictCursor)     # 연관배열형태

sql = " select * from adam_8025 order by adam_no asc "
curs.execute(sql)
#row = curs.fetchone()
read_data = curs.fetchall()

for read_row in read_data:
    print(read_row)

sql = "update adam_8025 set "
sql = sql + " no_1 = '" + str(1) + "' "
sql = sql + " where adam_no = '" + str(1) + "' "
curs.execute(sql)
dbcon.commit()


dbcon.close()

댓글목록

등록된 댓글이 없습니다.