Giter Club home page Giter Club logo

python-p3-intro-to-object-relational-mapping's Introduction

Intro to Object-Relational Mapping

Learning Goals

  • Create Python objects using SQL database records.
  • Create SQL database records using Python objects.

Key Vocab

  • Object-Relational Mapping (ORM): a technique used to convert database records into objects in an object-oriented language.

Introduction

As a relative newcomer to the programming world, terms like Object-Relational-Mapper, or ORM, can sound really intimidating. The nice part about ORM is that they can make it easier to write code once you understand them.

You’ve already written your fair share of SQL queries in the previous section. They usually look something like this:

SELECT * FROM schools WHERE name = 'Flatiron';

Object-relational mapping allows you to write queries like the one above, as well as much more complicated ones, using the object-oriented paradigm of your preferred programming language — in this case that would be Python.

In these lessons, we'll be covering these topics:

  • The benefits of ORM.
  • How ORMs can abstract database logic.
  • How to use data from a database to make Python objects.
  • Turning database rows into Python objects.
  • Mapping a database table to a Python object.

In this section, you'll get to write in the language you are already learning anyway. SQL is a powerful language, but most of us don’t write in it often. Being able to leverage the fluency of Python to perform these actions is awesome!

IMPORTANT NOTE: In this section, we'll be writing our very own Python ORM that maps Python objects to a SQL relational database. In the section following this one, we'll introduce an incredibly powerful Python ORM library called SQLAlchemy that will have some of the same features we're building here by hand, along with many, many more.

Just like the section on SQL, it's less important that you are able to gain mastery over writing your very own ORM. It's more important that you understand conceptually what an ORM is and how it works. So as long as you're able to follow the code and grasp what it's doing, you are in good shape!

Think of this section like building a soap-box car: It's a fun project, but ultimately, you wouldn't want to drive one every day! In the next section, you'll get the keys to the actual car (SQLAlchemy), along with our drivers ed course so that you can operate it safely.


Resources

python-p3-intro-to-object-relational-mapping's People

Contributors

professor-ben avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.