[英]Exception occured while fetching the records near “table”: syntax error In Python
Code:
import sqlite3
def create_connection(db_file):
try:
conn = sqlite3.connect("vienkarsaDB.db3")
except Exception as err:
print("Exception occured while trying to make connection", err)
else:
try:
cur=conn.cursor()
query= """SELECT * Cilvēki"""
cur.execute(query)
row=cur.fetchall()
print(row)
except Exception as err:
print("Exception occured while fetching the records", err)
else:
print("Completed")
finally:
cur.close()
finally:
conn.close()
return conn
create_connection("vienkarsaDB.db3")
Outprint:出处:
Exception occured while fetching the records near "Cilvēki": syntax error
I want to print my SQL table row, which I have imported, row name, table name, checked, both names entered correctly.我想打印我已经导入的 SQL 表行,行名,表名,检查,两个名称都输入正确。 Can anybody explain why it didn't print what I wanted?谁能解释为什么它没有打印出我想要的东西? Thank you!谢谢!
Syntax of your query is not right.您的查询语法不正确。 You need to use from before table name您需要在表名之前使用from
Instead of代替
SELECT * Cilvēki
Please use请用
SELECT * from Cilvēki
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.