WEBVTT

1
00:00:00.210 --> 00:00:01.630
<v ->Hi guys and welcome back.</v>

2
00:00:01.630 --> 00:00:03.080
In this video we're going to learn

3
00:00:03.080 --> 00:00:05.680
how to instal and use PostgreSQL,

4
00:00:05.680 --> 00:00:08.010
although really we won't be installing it at all.

5
00:00:08.010 --> 00:00:10.010
We're going to be using for this course,

6
00:00:10.010 --> 00:00:12.210
a cloud PostgreSQL provider.

7
00:00:12.210 --> 00:00:13.980
That means that instead of installing Postgres

8
00:00:13.980 --> 00:00:14.940
in my computer,

9
00:00:14.940 --> 00:00:18.050
I'm gonna use somebody else's installation on a server,

10
00:00:18.050 --> 00:00:20.190
an internet connected computer.

11
00:00:20.190 --> 00:00:22.650
That is because installing Postgres can be quite tricky.

12
00:00:22.650 --> 00:00:25.960
There's multiple problems that can arise in the process,

13
00:00:25.960 --> 00:00:28.170
so that's why we're gonna use that.

14
00:00:28.170 --> 00:00:29.660
These often cost money,

15
00:00:29.660 --> 00:00:32.500
but this provider ElephantSQL has a free tier

16
00:00:32.500 --> 00:00:34.720
from which we can learn more about Postgres

17
00:00:34.720 --> 00:00:35.710
without having to go through

18
00:00:35.710 --> 00:00:37.810
the pain of installing it ourselves.

19
00:00:37.810 --> 00:00:39.960
We often use these cloud providers

20
00:00:39.960 --> 00:00:41.400
when we're developing applications

21
00:00:41.400 --> 00:00:43.300
and they have a number of benefits

22
00:00:43.300 --> 00:00:46.060
as well as convenience for cost.

23
00:00:46.060 --> 00:00:48.300
You also get things like backups.

24
00:00:48.300 --> 00:00:50.330
You get things like load balancing.

25
00:00:50.330 --> 00:00:52.170
If you're making too many concurrent connections,

26
00:00:52.170 --> 00:00:53.830
you can sort of upgrade your server

27
00:00:53.830 --> 00:00:56.960
and allow for more of those for a higher cost of course.

28
00:00:56.960 --> 00:00:58.270
And so there's a few benefits

29
00:00:58.270 --> 00:01:00.290
that come with using a cloud provider

30
00:01:00.290 --> 00:01:01.330
and the main one is of course

31
00:01:01.330 --> 00:01:03.140
that you don't have to set it up yourself

32
00:01:03.140 --> 00:01:04.300
and manage it yourself.

33
00:01:04.300 --> 00:01:07.240
For example, if you've run out of disc space, et cetera.

34
00:01:07.240 --> 00:01:10.320
So the first thing to do is to go to ElephantSQL.com

35
00:01:10.320 --> 00:01:12.003
and sign up for an account.

36
00:01:13.100 --> 00:01:13.933
So once you've done that,

37
00:01:13.933 --> 00:01:15.700
you're gonna end up in somewhere like this.

38
00:01:15.700 --> 00:01:17.280
I've already got a few Instances

39
00:01:17.280 --> 00:01:19.050
or database servers running,

40
00:01:19.050 --> 00:01:21.120
but you can create a new one.

41
00:01:21.120 --> 00:01:22.450
It is possible that you'll see this

42
00:01:22.450 --> 00:01:24.180
as the default screen when you come in

43
00:01:24.180 --> 00:01:25.600
and if so, that's totally fine.

44
00:01:25.600 --> 00:01:27.310
Just go ahead and give it a name.

45
00:01:27.310 --> 00:01:31.090
I'm gonna give it Python/PostgreSQL 2.0 course

46
00:01:31.090 --> 00:01:33.500
then select the free plan and finally

47
00:01:33.500 --> 00:01:34.640
you can put in some tags

48
00:01:34.640 --> 00:01:37.740
if you want to structure or organise your servers

49
00:01:37.740 --> 00:01:38.820
in a specific way,

50
00:01:38.820 --> 00:01:40.580
but we can leave it empty for now.

51
00:01:40.580 --> 00:01:41.870
Then select the region.

52
00:01:41.870 --> 00:01:45.090
Here we're gonna select a region that's near us

53
00:01:45.090 --> 00:01:46.700
because the apps that we're gonna be building

54
00:01:46.700 --> 00:01:50.530
in this course are gonna run in our computers

55
00:01:50.530 --> 00:01:52.960
and the closer the server is to our computer,

56
00:01:52.960 --> 00:01:55.060
the faster the connection is gonna go.

57
00:01:55.060 --> 00:01:57.600
If we were deploying these applications

58
00:01:57.600 --> 00:01:59.530
that we're building to a server

59
00:01:59.530 --> 00:02:01.850
for other users to connect to,

60
00:02:01.850 --> 00:02:04.100
then we would want to pick a database

61
00:02:04.100 --> 00:02:07.870
that is near our users instead of near us,

62
00:02:07.870 --> 00:02:09.290
but for now we're gonna leave it as that.

63
00:02:09.290 --> 00:02:11.460
I'm gonna pick Ireland and that's it.

64
00:02:11.460 --> 00:02:13.850
We can create the Instance after that.

65
00:02:13.850 --> 00:02:15.710
All right, so once you've got your Instance created,

66
00:02:15.710 --> 00:02:17.410
you can click on it

67
00:02:17.410 --> 00:02:20.640
and here you're going to see details for this Instance.

68
00:02:20.640 --> 00:02:23.030
We can see for example, the server.

69
00:02:23.030 --> 00:02:27.040
This is the location on the internet where this database is.

70
00:02:27.040 --> 00:02:30.300
This essentially resolves to an IP address

71
00:02:30.300 --> 00:02:34.220
that computers can use to connect from one to another.

72
00:02:34.220 --> 00:02:37.240
We've also got the user that the database is going to use.

73
00:02:37.240 --> 00:02:38.360
You're gonna need this together

74
00:02:38.360 --> 00:02:41.490
with the password in order to connect to the server.

75
00:02:41.490 --> 00:02:43.670
As well as that, we've got the URL.

76
00:02:43.670 --> 00:02:45.970
The URL contains all the information

77
00:02:45.970 --> 00:02:49.960
that normally code needs to connect to a Postgres database,

78
00:02:49.960 --> 00:02:52.540
so this URL contains the username,

79
00:02:52.540 --> 00:02:54.830
the password, the host, the port,

80
00:02:54.830 --> 00:02:57.700
that is a specific place in this IP address

81
00:02:57.700 --> 00:02:59.310
where the database is running

82
00:02:59.310 --> 00:03:01.460
as well as the default database.

83
00:03:01.460 --> 00:03:03.570
Whenever we connect it to this URL,

84
00:03:03.570 --> 00:03:05.830
we're already gonna have a database created

85
00:03:05.830 --> 00:03:07.520
and we can just go in and create tables

86
00:03:07.520 --> 00:03:09.203
and insert data and so forth.

87
00:03:10.150 --> 00:03:13.600
Using ElephantSQL we can also run arbitrary queries using

88
00:03:13.600 --> 00:03:15.190
the browser tab here on the left,

89
00:03:15.190 --> 00:03:17.250
we can run our queries, execute them,

90
00:03:17.250 --> 00:03:19.800
and see our output as well.

91
00:03:19.800 --> 00:03:21.570
Throughout the next few chapters,

92
00:03:21.570 --> 00:03:24.640
I'm going to be using the URL from my Python code

93
00:03:24.640 --> 00:03:25.980
as the database URL,

94
00:03:25.980 --> 00:03:27.490
So click on the 'I',

95
00:03:27.490 --> 00:03:29.160
copy the whole thing as you're gonna need it

96
00:03:29.160 --> 00:03:31.920
in the next few videos when we're working with Python.

97
00:03:31.920 --> 00:03:34.350
If you'd rather instal Postgres SQL locally

98
00:03:34.350 --> 00:03:37.010
instead of using ElephantSQL, you can do that.

99
00:03:37.010 --> 00:03:38.920
I'm gonna leave a link in the resources section

100
00:03:38.920 --> 00:03:41.610
of this video to the ebook where we cover

101
00:03:41.610 --> 00:03:43.700
how you can instal PostgreSQL locally,

102
00:03:43.700 --> 00:03:46.570
but again, sometimes there are some problems that arise

103
00:03:46.570 --> 00:03:47.910
when you're doing that

104
00:03:47.910 --> 00:03:50.350
and we're not really going to be able to help you with those

105
00:03:50.350 --> 00:03:53.180
as they can be very dependent on the computer

106
00:03:53.180 --> 00:03:55.230
that you're running and your operating system,

107
00:03:55.230 --> 00:03:57.310
your versions of different things and stuff like that.

108
00:03:57.310 --> 00:03:58.143
But nonetheless,

109
00:03:58.143 --> 00:04:00.120
I'm gonna leave a link there that can help you out.

110
00:04:00.120 --> 00:04:02.570
If instead of using this browser

111
00:04:02.570 --> 00:04:06.450
you want to use your own database viewer such as PG admin

112
00:04:06.450 --> 00:04:08.890
or HeidiSQL, which is the one I recommend,

113
00:04:08.890 --> 00:04:10.140
then you can totally do that.

114
00:04:10.140 --> 00:04:12.390
Those will need the URL

115
00:04:12.390 --> 00:04:14.030
so that they can connect to your database,

116
00:04:14.030 --> 00:04:16.590
but then the database will behave like any other one

117
00:04:16.590 --> 00:04:18.900
that you've got installed locally.

118
00:04:18.900 --> 00:04:21.880
The ebook also contains instructions on how to use HeidiSQL,

119
00:04:21.880 --> 00:04:23.100
which is a database viewer,

120
00:04:23.100 --> 00:04:24.460
so you can read that if you want

121
00:04:24.460 --> 00:04:26.880
to use a local database viewer instead

122
00:04:26.880 --> 00:04:29.160
of going through ElephantSQL.

123
00:04:29.160 --> 00:04:31.700
Do note though that I will be using ElephantSQL

124
00:04:31.700 --> 00:04:32.533
throughout the course.

125
00:04:32.533 --> 00:04:34.720
So everything that you're gonna see me do here,

126
00:04:34.720 --> 00:04:36.870
you're gonna need to use your local database viewer

127
00:04:36.870 --> 00:04:39.120
if you were using that instead.

128
00:04:39.120 --> 00:04:41.380
All right, now we're ready to move on to the next chapter

129
00:04:41.380 --> 00:04:42.360
where we're gonna learn more

130
00:04:42.360 --> 00:04:44.460
about how to interact with PostgreSQL.

131
00:04:44.460 --> 00:04:46.910
So thank you for watching and I'll see you there.

