1
00:00:00,179 --> 00:00:05,819
Hi there and I'm glad to introduce you
to this new section of the course, and in

2
00:00:05,819 --> 00:00:10,830
this section you're going to learn how
to interact with databases via Python

3
00:00:10,830 --> 00:00:16,379
and what that means is that you'll use
specific Python libraries, and you're

4
00:00:16,379 --> 00:00:22,710
going to operate a database from Python,
using Python. You're going to do

5
00:00:22,710 --> 00:00:27,660
operations such as inserting data into
the database tables you'll be able to

6
00:00:27,660 --> 00:00:33,149
update data or delete and query data
from the database. And then you are able

7
00:00:33,149 --> 00:00:38,579
to use those data in your Python program.
Python is able to interact with many

8
00:00:38,579 --> 00:00:47,039
databases such as MySQL, PostgreSQL
Oracle, or SQLite etc. In this section

9
00:00:47,039 --> 00:00:51,660
you're going to learn how to interact
with an SQLite database and the

10
00:00:51,660 --> 00:00:58,230
PostgreSQL database as well. SQLite and
PostgreSQL are different in that SQLite

11
00:00:58,230 --> 00:01:05,129
is not a client server database instead
it is embedded into the end program.

12
00:01:05,129 --> 00:01:10,770
So what does that mean? Well let's look at
this program. If you followed the previous

13
00:01:10,770 --> 00:01:14,240
section you know that we're going to
build this program in the next section.

14
00:01:14,240 --> 00:01:19,020
When you click a button here you see
some data and these data are stored in

15
00:01:19,020 --> 00:01:24,810
SQLite database. In contrast to other
databases such as PostgreSQL SQLite is

16
00:01:24,810 --> 00:01:31,110
based on file, so all this data here are
stored in a dot DB file, database file.

17
00:01:31,110 --> 00:01:35,520
So that means you can just give this
this problem to someone else who don't

18
00:01:35,520 --> 00:01:40,079
have SQLite installed and they can use
this program, so they can add more data

19
00:01:40,079 --> 00:01:43,200
here, can update data and you leave them
and so on.

20
00:01:43,200 --> 00:01:48,000
But if you have this program
in a PostgreSQL database, the user you

21
00:01:48,000 --> 00:01:52,380
give the program to they need to have
Postiglione installed in a computer

22
00:01:52,380 --> 00:01:58,530
tobe able to operate the data.
So consider SQLite a small database and

23
00:01:58,530 --> 00:02:03,509
you can call it portable, but it's very
popular and PostgreSQL would be more

24
00:02:03,509 --> 00:02:08,009
appropriate to use in a web application.
So let's say you have some forms you're

25
00:02:08,009 --> 00:02:11,530
getting some data from the user
on your website.

26
00:02:11,530 --> 00:02:16,569
You store your data on a PostgreSQL
database on your server and Python

27
00:02:16,569 --> 00:02:22,470
is the program that gets these data from
your forms on client, on the browser and

28
00:02:22,470 --> 00:02:28,050
sends those data in your database.
Now to be able to interact with these databases

29
00:02:28,050 --> 00:02:33,819
you need to have two libraries and these
libraries serve as interfaces

30
00:02:33,819 --> 00:02:39,550
to actually send SQL code to the database.
And the library to interact with an SQLite

31
00:02:39,550 --> 00:02:46,540
database is called Sqlite3 and the
library to work with a PostgreSQL

32
00:02:46,540 --> 00:02:52,600
database is psycopg2. So in this
section now in the next lecture I'll

33
00:02:52,600 --> 00:02:59,709
show how to work with SQLite 3 and then
we'll jump to psycopg2.

34
00:02:59,709 --> 00:03:01,890
So let's move on.

