我正在写一个程序来找出今天的日期和出生日期之间的区别。我试着用日期差来计算他们的年龄 一直返回此消息 sqlite3.OperationalError:靠近“(”:语法错误
def workoutage():
print ("Current date and time: " , datetime.datetime.now())
print ("Or like this: " ,datetime.datetime.now().strftime("%Y-%m-%d"))
today = datetime.datetime.now().strftime("%Y-%m-%d")
print("the date today is ", today)
con = lite.connect(db)
cur = con.cursor()
' - DateofBirth ) from Pupils"
ageQuery = "SELECT pupils.dateofBirth DATEDIFF(day, '"+today+",
pupils.dateofBirth) AS NumberOfDays from Pupils"""
cur.execute(ageQuery)
ageQueryList = cur.fetchall()
showList(ageQueryList)
SQL中的语法错误。在
错误信息非常明确。解析器在需要其他内容时遇到了
(
,而查询中只有一个(
。在一个
select
语句是select column, column, ...
,因此您需要在pupils.dateofBirth
后面加一个逗号。在相关问题 更多 >
编程相关推荐