March 10, 2024, 13:13
sqlalchemy.exc.ArgumentError: Mapper Mapper[VideoModel(video_model)] could not assemble any primary key columns for mapped table 'video_model'I tried installing using:
pip install Flask-SQLAlchemy sudo apt-get install python3-flask-sqlalchemyBoth worked and output that it's already installed.
python from flask import Flask from flaskrestful import Api, Resource, reqparse, abort from flask_sqlalchemy import SQLAlchemy app = Flask(__name) api = Api(app) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.db' db = SQLAlchemy(app) class VideoModel(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.string(100), nullable=False) views = db.Column(db.integer, nullable=False) likes = db.Column(db.integer, nullable=False) def repr(self): return f"Video(name={name}, views={views}, likes={likes})" db.create_all()