在PyCharm中,我在计算机上使用pymysql创建了一个MySQL模式。现在,我想使用Peewee创建表并编写SQL查询。但是,当试图连接到DB时,我总是会收到一条错误消息(见下面)。
用户有足够的权限在DB模式中创建表,因为它可以完美地处理pymysql (创建表以及模式都很好)。我在Stackoverflow上看了类似的问题,却找不到类似的问题。而且,在我看过的任何教程中,这个问题都没有经历过,所以我不完全确定是什么原因导致了错误。下面是一个最小的工作示例。
from peewee import*
import peewee
user = 'root'
password = 'root'
db_name = 'peewee_demo'
# The schema with the name 'peewee_demo' exists
db = MySQLDatabase(db_name, user=user, passwd=password)
class Book(peewee.Model):
author = peewee.CharField()
title = peewee.TextField()
class Meta:
database = db
db.connect() # Code fails here
Book.create_table()
book = Book(author="me", title='Peewee is cool')
book.save()
for book in Book.filter(author="me"):
print(book.title)我希望上面的代码能够连接到MySQL,然后在模式"peewee_demo“中创建一个新表。但是,代码在试图连接到DB时抛出一条错误消息:
/usr/bin/python3.6: Relink '/lib/x86_64-linux-gnu/libsystemd.so.0‘with
/lib/x86_64-linux-gnu/librt.so.1' for IFUNC symbolclock_gettime’
/usr/bin/python3.6: Relink /lib/x86_64-linux-gnu/libudev.so.1' with /lib/x86_64-linux-gnu/labt.so.1‘for IFUNC符号`clock_gettime’您知道如何解决这个问题吗?
提前感谢
发布于 2019-10-30 16:13:04
正如@coleifer在他的评论中指出的那样,错误可能与Python中的共享库问题有关。在设置了一个新的虚拟环境并安装了所有所需的软件包之后,一切都运行得非常好。
我只是加了一个答案才能结束这个问题。如果@coleifer将他的评论转换为回复,我将删除我的评论并接受他的评论。
https://stackoverflow.com/questions/58596701
复制相似问题