Python 必须指定连接条件,以获取此错误。
我正在尝试联接两个表以查看其内容Python 必须指定连接条件,以获取此错误。,python,mysql,orm,mysql-python,peewee,Python,Mysql,Orm,Mysql Python,Peewee,我正在尝试联接两个表以查看其内容 Users.select().join(User_profiles).where(Users.users_id == User_profiles.users_id) 我的用户型号: class Users(Model): users_id = PrimaryKeyField() username = CharField() password = CharField() mobile_number = CharField()
Users.select().join(User_profiles).where(Users.users_id == User_profiles.users_id)
我的用户型号:
class Users(Model):
users_id = PrimaryKeyField()
username = CharField()
password = CharField()
mobile_number = CharField()
created_at = DateTimeField()
updated_at = DateTimeField()
class Meta:
database = db_connection()
class User_profiles(Model):
users_id = IntegerField()
user_profiles_id = PrimaryKeyField()
profile_name = CharField()
address = CharField()
created_at = DateTimeField()
updated_at = DateTimeField()
class Meta:
database = db_connection()
我的用户配置文件模型:
class Users(Model):
users_id = PrimaryKeyField()
username = CharField()
password = CharField()
mobile_number = CharField()
created_at = DateTimeField()
updated_at = DateTimeField()
class Meta:
database = db_connection()
class User_profiles(Model):
users_id = IntegerField()
user_profiles_id = PrimaryKeyField()
profile_name = CharField()
address = CharField()
created_at = DateTimeField()
updated_at = DateTimeField()
class Meta:
database = db_connection()
我已将“用户模型”中的“用户id”指定为“用户配置文件模型”的外键。如何以正确的方式指定连接条件?我读过peewee文档,做过谷歌搜索,但没有任何帮助。有人能帮我写代码吗?我认为
用户配置文件\u id
应该写成用户配置文件\u id=ForeignKeyField(用户)