Python中文
首页
教程
问答
标签
搜索
登录
注册
sqlite中的日期搜索不起作用
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我正在试图搜索一个数据库的明日日期,然后进行电子邮件功能。你知道吗</p> <pre><code>def send_email(): currentdate = time.strftime("%d/%m/%Y") nextday = datetime.date.today() + datetime.timedelta(days=1) tomorrow = str(nextday.strftime("%d %m %Y")) with sqlite3.connect("school.db") as db: cursor = db.cursor() cursor.execute("SELECT DateIn FROM MusicLoan WHERE DateIn = ?",(tomorrow,)) row = cursor.fetchall()[0] if str(row) == str(tomorrow): cursor.execute("SELECT StudentID FROM MusicLoan WHERE DateIn = ?", (currentdate)) ID = cursor.fetcone()[0] cursor.execute("SELECT email FROM Student WHERE StudentID = ?",(ID)) email = cursor.fetchone()[0] fromaddr = email toaddr = "danielarif@blueyonder.co.uk" msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = toaddr msg['Subject'] = "Music Reminder" body = "A reminder that your music is due in tomorrow" msg.attach(MIMEText(body, 'plain')) try: server = smtplib.SMTP('smtp.gmail.com', 587) server.ehlo() server.set_debuglevel(1) server.starttls() server.ehlo() server.login("danielarif123@gmail.com", "DanR0bJ0nes3") text = msg.as_string() server.sendmail(fromaddr, toaddr, text) server.quit() print("Email Sent Successfully") send_email() except smtplib.SMTPException: print ("Error: unable to send email") send_email() </code></pre> <p>我的问题是它到达行=游标.fetchall()[0],然后停止。 我该怎么解决这个问题</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>你知道吗游标.执行(“从MusicLoan中选择DateIn,其中DateIn=?”(明天)</p> <p>并使用一种方法游标.fetchone()</p> <p>有关更多示例,请参阅<a href="https://docs.python.org/2/library/sqlite3.html" rel="nofollow">https://docs.python.org/2/library/sqlite3.html</a></p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
jupyter运行一个旧的pytorch版本
9 回答
Jupyter运行不同版本的卸载库?
10 回答
Jupyter运行指定的键盘快捷键
4 回答
Jupyter通过.local文件“逃逸”virtualenv。我该如何缓解这种情况?
10 回答
Jupyter重新加载自定义样式
7 回答
Jupyter错误:“没有名为Jupyter_core.paths的模块”
8 回答
jupyter错误:无法在随机林中将决策树视为png
10 回答
Jupyter错误'内核似乎已经死亡,它将自动重新启动'为一个给定的代码块
3 回答
Jupyter错误地用阿拉伯语和字母数字元素显示Python列表
4 回答
Jupyter隐藏数据帧索引,但保留原始样式
5 回答
Jupyter集线器:启动器中出现致命错误。。。系统找不到指定的文件
4 回答
Jupyther中相同值的相同哈希,但导出到Bigquery时不相同
8 回答
Jupy上Python的读/写访问问题
4 回答
jupy上没有模块cv
2 回答
Jupy上的排序错误
1 回答
Jupy中bqplot图形的紧凑布局
7 回答
Jupy中matplotlib plot的连续更新
8 回答
Jupy中Numpy函数的文档
8 回答
Jupy中Pandas的自动完成问题
4 回答
jupy中Qt后端的Matplotlib动画
6 回答