0
で供給されるバインディング:正しくないが、私はCIFファイルからデータベースを作成しようとしている、と奇妙なエラーを取得していますsqlite3の
import sqlite3 as sq
sqlfile = "mats.db"
tabnm = "elems"
id_col = "Properties"
val_col = "Value"
conn = sq.connect(sqlfile)
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS Trial
(Properties text, Name text, Phase text, AbM text, AbB text, Cpre text)''')
lists = []
filename = "/var/tmp/1101142.cif"
fullparams=["_journal_coden_ASTM" , "_journal_issue", "_journal_name_full"
,"_journal_page_first","_journal_page_last","_journal_paper_doi"
,"_journal_volume","_journal_year","_chemical_formula_sum"
,"_chemical_formula_weight","_space_group_IT_number","_symmetry_cell_setting"
,"_symmetry_space_group_name_Hall","_symmetry_space_group_name_H-M ","_atom_sites_solution_primary"
,"_atom_sites_solution_secondary ","_audit_creation_method","_cell_angle_alpha"
,"_cell_angle_beta","_cell_angle_gamma","_cell_formula_units_Z"
,"_cell_length_a","_cell_length_b","_cell_length_c"
,"_cell_measurement_reflns_used","_cell_measurement_temperature","_cell_measurement_theta_max"
,"_cell_measurement_theta_min","_cell_volume"]
with open(filename, "r") as cif:
for line in cif:
for j in range(6):
if line.startswith(fullparams[j]):
# print(line)
lists.append(line.split()[-1])
print(lists)
c.executemany("INSERT INTO Trial VALUES(?, ?, ?, ?, ?, ?)",lists)
conn.commit()
私は数が同じで、私はまだエラーを取得しています確認しましたが:
Python 3 SQLite3 - Incorrect number of bindings、 sqlite3 - Incorrect number of bindings suppliedが、私の問題を解決するカント:python3 parse_cif.py
['CMATEX', '7', "Materials'", '1745', '1752', '10.1021/cm0513738']
Traceback (most recent call last):
File "parse_cif.py", line 36, in <module>
c.executemany("INSERT INTO Trial VALUES(?, ?, ?, ?, ?, ?)",lists)
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 6, and there are 1 supplied.
は、私はそれが私はすでに同様の質問を見られるように求めている指定された値1をカウントしているか分かりません。
助けてください。