我正在尝试加入2个表来查看其内容。
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()
我的 User_profiles模型:
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()
我已将“Users Model”中的“users_id”指定为“User_profiles Model”的外键。如何以正确的方式指定连接条件?我读过peewee doc并进行Google搜索,但没有任何帮助。有人可以帮我处理代码吗?