Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用 MySQLdb 从 python 访问 mysql 数据库。我需要知道与数据库的连接是否仍然存在......是否有任何属性或方法可以做到这一点???
谢谢!!
说实话,我已经很久没有在python中使用过mysqldb了。
话虽如此,我建议使用 execute("now()") (或“select 1”,任何其他“虚拟” SQL 命令)并处理任何错误。
编辑:这也应该是您正在使用的课程的一部分。不要在每一行都用 .execute("now()") 填充整个项目。;)