0% found this document useful (0 votes)
2 views1 page

Quiz Master Notes

The document discusses Object Relational Mapping (ORM) and its ability to manage database interactions through objects, specifically using Sqlalchemy. It provides a brief overview of testing a database in a Flask application, including creating and querying a subject. The example demonstrates how to add a subject to the database and retrieve its details using Python code.

Uploaded by

anupamprasad58
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Quiz Master Notes

The document discusses Object Relational Mapping (ORM) and its ability to manage database interactions through objects, specifically using Sqlalchemy. It provides a brief overview of testing a database in a Flask application, including creating and querying a subject. The example demonstrates how to add a subject to the database and retrieve its details using Python code.

Uploaded by

anupamprasad58
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 1

ORM – object relational mapper .

It directly deals with the objects , relation between the objects


convert the sql query in the databases , flexible to any databases. you have to write once that
supports the data bases. Whole access to the data bases. We will use Sqlalchemy at the orm .

Testing the database


Flask shell – python based intractive shell . It connect with the application , App is there , (Instance)
the database connection is also there .for testing create a subject

from app import db


from app.models import subject
#to create a subject we have to write in a way .
math_subject = Subject(name=“Math ” , description=“ In this subject , we will learn math
concepts”)
#db.session – intract to the database
db.session.add(math_subject)
db.session.commit() -> it saves the data that we have added to the database.
#now query the record.
Subjects = subject.query.all()
subject = subjects[0]
#<Subject 1> we get the objects
Subject.name
subject.description
exit()

You might also like