For all the self-taught geeks out there, here our content library with most of the learning materials we have produces throughout the years.
It makes sense to start learning by reading and watching videos about fundamentals and how things work.
Machine Learning Engineering (16 weeks)
Full-Stack Software Developer
Search from all Lessons
Curated list of small interactive and incremental exercises you can take to get better at any coding skill.
Curated section of projects to build while learning with simple instructions, videos, solutions and more.
Guides on different topics related to the technologies that we teach in our courses
Social & live learning
The most efficient way to learn: Join a cohort with classmates just like you, live streams, impromptu coding sessions, live tutorials with real experts, and stay motivated.
SQL Alchemy is an Object-Relational Mapper / Mapping-tool, or ORM: a library that developers use to create databases and manipulate their data without the need of knowing/using SQL.
There are other alternatives to it like SQLAlchemy like Peewee, and other languages have their own ORM's like PHP Eloquent or Java Hibernate.
ORM's have gained popularity because dealing with SQL language directly requires a lot of effort in many cases. The goal of any ORM is to simplify the maintenance of your data. This is done by creating objects to deal with database interactions.
With ORM you won't have to type SQL again (95% of the time) and you will be able to work with objects.
To insert an user with SQL you have to type:
With an ORM your code keeps being familiar like this:
You can just say:
db.session.commit() and all the things you have done in your code will be translated into SQL language code.
The first step will be defining our model
All you have to do is create a new Person object, add it into the database session and commit!
<email_value> with the real values you want added below.
There are 3 ways to retrieve data from a database:
1. Fetch all record from a particular Table/Model using
2. Fetch one single record based on its primary key using
3. Fetch a group of records based on a query
Person.query.filter_by(arg1=value, arg2=value, ...)
All you have to do is select the instance of a Person you would like to delete (ie. by it's id) and delete it by typing db.session.delete(person)
To update you need first to retrieve/select the record from the database, then you can update whatever property you like and commit again.
A transaction is a sequence of operations (like INSERT, UPDATE, SELECT) made on your database. In order for a transaction to be completed a number of operations within a group must be successful. If one operation fails, the whole transaction fails.
Transactions have the following 4 standard properties(known as ACID properties):
A transaction ends with COMMIT or ROLLBACK.
COMMIT command is used to permanently save any transaction into the database.
When you use INSERT, UPDATE or DELETE, the changes made by these commands are not permanent, the changes made by these commands can be undone or "rolled back".
If you use the COMMIT command though the changes to your database are permanent.
It restores the database to last your last COMMIT. You can also use it with SAVEPOINT command to jump to a savepoint in a ongoing transaction.
Also, if you use UPDATE to make changes to your database, you can undo them by using the ROLLBACK command but only if you haven't commited those changes like this:
This command is used to temporarily to save a transaction so that you can go back to a certain point by using the ROLLBACK command whenever needed, you can use like this:
This command may be called many times, and it will issue a new CHECKPOINT with an ID.
Now let's say we go out to have some pizza. Our pizza comes with three ingredients basic ingredients: mozzarella, tomato, olives. Our table called 'PIZZA' would look like this:
But we have a list of extra ingredients we can add to it: first we choose meat but then we change our mind and we want to add mushrooms instead. We would also like to add some pepperoni and bacon. Let see how could we do that:
Now our 'PIZZA' has the following ingredients:
Now we have decided we no longer want bacon, so we use ROLLBACK:
and our pizza looks like this:
....I'm a bit hungry after reading this lesson!! aren't you??