Skip to content
Advertisement

I want to add data to my table using ORM in python

I want to add data in my database using ORM, and i am new to ORM in python. I am confused in SQLAlchemy and Flask-SQLAlchemy.”I tried this but don’t know how to proceed further


JavaScript

Advertisement

Answer

Flask-SqlAlchemy is commonly used for flask applications, otherwise just plain SqlAlchemy would should be enough.

Flask-SqlAlchemy is a wrapper over SqlAlchemy and gives you following advantages:

  1. A preconfigured scoped session, engine and metadata.
  2. Model base class which is configured declarative base.
  3. Model base class has query attribute attached to it which can be used to query the model.
  4. You don’t need to remove the session at the end of your commit.

Here is how you can use your SqlAlchemy code.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement