Hi there, and I'm glad to introduce you
to this new section of the course. And
in this section, you're going to learn
how to interact with databases via
Python. And what that means is that you
will use specific Python libraries, and
you're going to operate a database from
Python, using Python. You're going to do
operations such as inserting data into
database tables, you would be able to
update date, delete and query data all from
the database. And then you are able to
use those data in your Python program.
Python is able to interact with many
databases such as MySQL, PostgreSQL,
Oracle, or SQLite, etc. In this
section, you're going to learn how to
interact with an SQLite database and
the PostgreSQL database as well. SQLite and PostgreSQL
are different in that, SQLite is not a client server
database, instead, it is embedded into
the end program. So what does that mean?
Well, let's look at this program.
If you followed the previous section, you know
that we're going to build this program
in the next section. When you click a
button here, you see some data, and
these data are stored in SQLite
database. In contrast to other databases
such as PostgreSQL, SQLite is based on
file. So all these data here are stored
in a .db file database file, so that
means you can just give this
program to someone else who don't have
SQLite installed, and they can use
this program. So they can add more data
here, can update data, and delete them and
so on. But if you have this program, you
know, PostgreSQL database, the user, you
give the program to they would need to
have PostgreSQL installed in the
computer to be able to operate the data.
So consider SQLite a small database,
and you can call it portable, but it's
very popular, and PostgreSQL would be
more appropriate to use in a web
application. So let's say you have some
forms, you're getting some data from, from
the user on your website, and you store
your data on a PostgreSQL database on
your server. And Python is a program
that gets these data from your forms on
the client, on the browser and
sends those data in your database. Now
to be able to interact with this
databases, you need to have two
libraries. Now these libraries serve as
interfaces to actually send SQL code to
the database. And the library to
interact with an SQLite database is
called sqlite3, and the library
to work with a PostgreSQL database is
psycopg2. So in this section now, in
the next lecture, I'll show how to work
with sqlite3. Then we'll jump to
psycopg2. So let's move on.