2017-12-18 13 views
0

SQLite를 배우고 있고 값을 저장하고 아래 프로그램의 추출 된 코드 줄을 사용하여 문자열을 검색하려고 시도했지만 계속 오류가 발생합니다. "execute()는 키워드 인수를 사용하지 않습니다. . " sqlite3를 DB API는이 데이터베이스를 참조하는 올바른 방법이다라고 때문에 이해가 안 :SQLite 실행 오류

import sqlite3 
dbb = sqlite3.connect('finance.db') 
db = dbb.cursor() 
username = request.form.get("username") 

#query database for username 
rows = db.execute("SELECT * FROM users WHERE username = :username", \ 
username=username) 

답변

0

documentation는 말한다 :

sqlite3 모듈이 자리의 두 종류 지원 : 질문 마크 (qmark 스타일) 및 명명 된 자리 표시 자 (스타일 이름).

여기 두 스타일의 예 :

# This is the qmark style: 
cur.execute("insert into people values (?, ?)", (who, age)) 

# And this is the named style: 
cur.execute("select * from people where name_last=:who and age=:age", {"who": who, "age": age}) 

키워드 인수가 지원되지 않습니다. 그러나 명시 적으로 사전으로 변환 할 수 있습니다 (execute에 대한 래퍼 작성).

+0

감사합니다. qmark 스타일은 아직 고려하지 않은 템플릿 작성 방법에 대해 완벽하게 작동합니다. – tiff