sqlite3을 사용하여 python으로 sqlite 데이터베이스를 만들려고합니다. 여기에 각각 하나의 필드 열만있는 table_names
에 지정된 이름으로 새 테이블을 만듭니다. conn.execute('CREATE TABLE {} (quote TEXT PRIMARY KEY NOT NULL);'.format(table_names[i]))
및 quote
파일을 읽는 중입니다. 그러나 나는 insert 문을 실행할 수 없다. 그리고 나는 아래에 내가 시도한 것과 실패한 것을 게시했다. 어떤 도움을 주시면 감사하겠습니다. SQL에 따옴표 모든 문자열이기 때문에 덕분에Python sqlite error
conn.execute('''INSERT INTO {} (quote) VALUES ('{}')'''.format(table_names[i], quote))
Error : sqlite3.OperationalError: near "s": syntax error
conn.execute('''INSERT INTO {} (quote) VALUES ('?')'''.format(table_names[i]), (quote,))
Error : sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are 1 supplied.
conn.execute('''INSERT INTO ? (quote) VALUES ('?')''', (table_names[i], quote))
Error : sqlite3.OperationalError: near "?": syntax error
당신이 bar''의 값에 변수'foo'를 지정하려는 경우, 당신은'foo는 = "바"'합니까? –
@ColonelThirtyTwo 실수를했습니다. 감사합니다. – sujithvm