We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to support FileField with SQLModel? I'm aware of sqlalchemy-file, which is for sqlalchemy to handle file field. Can we still use it with SQLModel?
The text was updated successfully, but these errors were encountered:
Does this answer resolve your question?
from sqlalchemy import Column, String from sqlalchemy_file import FileField, FileConverter from sqlmodel import SQLModel, create_engine, Session class MyModel(SQLModel): __tablename__ = "my_table" id = Column(Integer, primary_key=True) name = Column(String) file = Column(FileField(converter=FileConverter(url="uploads/"))) # Define file field and converter engine = create_engine("sqlite:///my_database.db") SQLModel.metadata.create_all(engine) session = Session(engine) # Example usage new_model = MyModel(name="My File", file="path/to/your/file.txt") session.add(new_model) session.commit() session.close()
Sorry, something went wrong.
The FileConverter import fails :/
@gioscarda, it is a separate package to be installed with: pip install sqlalchemy-file
pip install sqlalchemy-file
No branches or pull requests
How to support FileField with SQLModel? I'm aware of sqlalchemy-file, which is for sqlalchemy to handle file field. Can we still use it with SQLModel?
The text was updated successfully, but these errors were encountered: