when i insert admin or role, i get ‘Multiple classes found for path "Userlogs" in the registry of this declarative base’?

i'm using db.metadata.clear() clear db mapping, when i insert admin or role, i get the error:

sqlalchemy.exc.InvalidRequestError: Multiple classes found for path "Userlogs" in the registry of this declarative base. Please use a fully module-qualified path.

from app import db
from datetime import datetime


class User(db.Model):
    会员, info简介, face图像, add_time注册时间, uuid唯一标识
    __tablename__ = 'user'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), unique=True)
    pwd = db.Column(db.String(100))
    email = db.Column(db.String(100), unique=True)
    phone = db.Column(db.String(11), unique=True)
    info = db.Column(db.Text)
    face = db.Column(db.String(255), unique=True)
    add_time = db.Column(db.DateTime, index=True, default=datetime.now)
    uuid = db.Column(db.String(255), unique=True)
    user_logs = db.relationship('Userlogs', backref='user')  # 会员日志外键关联
    comments = db.relationship('Comment', backref='user')
    moviecols = db.relationship('Moviecol', backref='user')

    def __repr__(self):
        return '<User %r>' % self.name

class Userlogs(db.Model):
    __tablename__ = 'user_logs'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))  # db.ForeignKey()创建外键
    ip = db.Column(db.String(100))
    add_time = db.Column(db.DateTime, index=True, default=datetime.now)

    def __repr__(self):
        return '<Userlogs %r>' % self.id

Flask: 1.1.2

jinja2: 2.11.1

Read more here: https://stackoverflow.com/questions/68463038/when-i-insert-admin-or-role-i-get-multiple-classes-found-for-path-userlogs-i

Content Attribution

This content was originally published by labike at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: