공통 import
from sqlite3 import * #pip install pysqlite3
from dbconnect import *
from random import *
#update
for a in range(20,23): #sql index 고유값 범위선정
    cur= connect.cursor()
    #해당 index값 모두 변경 되게 반복 시킴
    sql = "update test3 set mpw='pass1234' where midx='"+str(a)+"'"
    #%s 사용시 sql 문법 전체를 %s로 적용해야만 정상적으로 반영 
    cur.execute(sql)
    connect.commit()20~22번 insert 이후 update

#delete
cur=connect.cursor()
for b in range(20,23):
    sql="delete from test3 where midx='"+str(b)+"'"
    cur.execute(sql)
    connect.commit()
20~22번 삭제

#create
cur = connect.cursor()
sql="create table shopping(sidx int(4) not null AUTO_INCREMENT,sname varchar(200),primary key(sidx))"
cur.execute(sql)테이블 생성

728x90
    
    
  'Python > Python' 카테고리의 다른 글
| Python 야구리그 순위권 팀명 추출하기 (0) | 2022.09.22 | 
|---|---|
| Python 네이버 웹툰 인기 순위 10 제목 추출하기 (0) | 2022.09.22 | 
| BeautifulSoup/ requests / LXML 모듈 (0) | 2022.09.22 | 
| Python 배열, 튜플 (0) | 2022.09.21 | 
| Pyhton 배열 (0) | 2022.09.21 | 
 
										
									 
										
									 
										
									 
										
									
댓글