Skip to content

Inheriting UserMixin class from flask-login library on SQLModel model crashes the app  #476

@km-monzurul-islam

Description

@km-monzurul-islam

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the SQLModel documentation, with the integrated search.
  • I already searched in Google "How to X in SQLModel" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to SQLModel but to Pydantic.
  • I already checked if it is not related to SQLModel but to SQLAlchemy.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

from flask import Flask
from sqlmodel import SQLModel, Field, create_engine
from flask_login import UserMixin

class Account(UserMixin, SQLModel, table=True):
    id: int | None = Field(default=None, primary_key=True)
    name: str
    scotia_id: str = Field(unique=True)
    email: str = Field(unique=True)
    password: str


engine = create_engine('sqlite:///site.db')
SQLModel.metadata.create_all(engine)

app = Flask(__name__)
if __name__ == '__main__':
    app.run(debug=True)

Description

(project) ➜ project python test.py
Traceback (most recent call last):
File "/home/johnny/project/test.py", line 5, in
class Account(UserMixin, SQLModel, table=True):
File "/home/johnny/.local/share/virtualenvs/project-ABytqz7n/lib64/python3.10/site-packages/sqlmodel/main.py", line 322, in init
config = getattr(base, "config")
AttributeError: type object 'UserMixin' has no attribute 'config'

Operating System

Linux

Operating System Details

Fedora 36 Gnome Desktop

SQLModel Version

0.0.8

Python Version

Python 3.10.7

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions