Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 모바일게임
- 컴투스 신작
- 스팀세일
- 신창섭
- 게임 트렌드
- 신의탑
- 프로그래밍
- 메이플스토리
- 뉴맞고
- NC
- c#
- 윈폼
- 게임
- 메이플 여름 쇼케이스
- 넥슨
- 게임신작
- 스팀 할인
- ToyProject
- 넷마블
- 메이플
- 컴투스
- 스팀
- 신의탑 게임
- 파이썬 오류
- 추억의 게임
- 코딩
- 메이플 쇼케이스
- 김창섭
- 설문조사 결과산출
- 여름게임
Archives
- Today
- Total
JY Tech
[파이썬,sqlite] incorrect number of bindings supplied. the current statement uses 1 and there are 3 supplied 본문
Programming/Error Solution
[파이썬,sqlite] incorrect number of bindings supplied. the current statement uses 1 and there are 3 supplied
J.Dragon 2023. 4. 21. 14:16cur.execute("SELECT tool_Name FROM Tool WHERE tool_Name=?",(toolName,))
파이썬과 sqlite를 활용한 프로그램을 만들면서 아래와 같은 코드를 작성했는데
incorrect number of bindings supplied. the current statement uses 1 and there are 3 supplied
이런 오류가 발생했다.
구글링을 해 보니 해결법은 생각보다 간단했다.
cur.execute는 튜플을 전달해야 되는데 (toolName)의 형태로 값만 전달해서 그렇단다(데이터 바인딩 오류).
튜플로 값을 전달하기 위해 , 만 추가해 주면 된다
따라서 코드를 다음과 같이 수정하면 된다.
cur.execute("SELECT tool_Name FROM Tool WHERE tool_Name=?",(toolName,))
다시 코드를 실행하면 오류가 해결된 것을 확인할 수 있다.
참고로 위에서는 ?가 하나여서 전달하는 값이 하나이기 때문에 오류가 발생한 것이고
cur.execute("SELECT * FROM Book WHERE book_User=? AND book_Phone=? AND book_Tool=? AND book_Count=?",(person, phone, toolName, quantity))
와 같이 전달하는 값이 여러개라면 ,를 추가하지 않아도 된다.
한줄요약: 파이썬에서 sqlite를 사용하고 ?를 사용하여 쿼리문을 작성할 때 값이 하나만 전달될 경우 끝부분에 ,를 추가해야 한다.
'Programming > Error Solution' 카테고리의 다른 글
[파이썬] raise KeyError(key) from err (1) | 2023.11.27 |
---|---|
[파이썬]xlrd.biffh.XLRDError(xlrd오류) (1) | 2023.11.10 |
[C#/윈폼]"도구상자 항목 '###'을(를) 로드하지 못했습니다. 해당 항목은 도구상자에서 제거됩니다. (0) | 2023.04.30 |
파이썬 TypeError: can only concatenate str (not "list") to str (0) | 2023.04.04 |
y must have at least two dimensions for multi-output regression but has only one. 오류 (1) | 2023.02.16 |