Database Layer
- We need to figure out a way to interact with database
- From the design perspecive we have two options
- Executing SQL Statements
- ORM Frameworks
Python to Database using raw sql statements
-
Databases: On a larger note we have two types of databases
-
Relational Databases:
-
Here data is stored in tabular formats and tables can have relationships between them

-
There are two types of keys
- primary key
- foreign key
- To interact with these databases there is a standard SQL (Structured Query Language)
- This standard is implemented by database management softwares
- SQL Standard
- CREATE
- UPDATE
- DELETE
- Retrieve/SELECT
- NO-SQL
-
-
-
Prompt for SQL
you are an expert in database,
Help me in learning and writing sql statements of postgres database for a simple school management system
Explain Each topic, give some examples wait, then go to next
SQLite
- This is a database which stores all of its data in a file
-
Python standard library supports this
-
Refer Here for code done and watch classroom recording for sqlite and postgres related db connection and executing queries
ORM (Object Relational Mapping)
-
ORM gives
- Cleaner code
- Reusable models
- relationships
- migrations
- type safety
- abstracts db engine
-
Popular ORM Frameworks
- SQLAlchemy
- Django ORM
SQL ALchemy
-
Refer Here for the changes
-
Refer Here for orm posgtres and Refer Here for direct query executions
-
Refer Here for direct of sqlite and Refer Here for orm version
