Effective PyCharm (2021 edition) Transcripts
Lecture: Adding database connections
0:00 Let's start exploring this database in PyCharm.
0:03 You know, if you look over to the right there might have been this temptation
0:07 to open this database tab and yeah,
0:10 here we go, it's time to dive into this section.
0:12 So we need to start by adding a data source and says you can do that
0:16 by hitting 'cmd+n' or you can just click on this and there's a bunch of
0:21 different options. We can download some stuff from URL's
0:24 And whatnot. But we can open this up and it'll show us basically
0:27 the list of databases that are supported and there are many we've got Amazon,
0:31 RedShift, Cassandra, Hive, BigQuery, CockroachDB,
0:37 some Exasol thing, Greenplum,
0:39 which I've actually never even heard of IBM DB2.
0:43 Scroll and some here we got Maria DB Microsoft,
0:46 SQL server, Mongo DB which is really cool to have that no SQL database in
0:50 there. Got My SQL, Oracle, PostgresSQL, SQLite.
0:53 This is the one that we're using Snowflake and some others.
0:56 Right? So you can see that there's actually even basic support for a whole bunch
1:01 of other types of databases here.
1:03 So again, pick the one that you want.
1:05 The tools are pretty similar. We're gonna pick this.
1:09 Now notice I'm glad this came up like this here,
1:12 notice that there's this download machine drivers because there's so many different databases supported PyCcharm
1:19 doesn't want to ship like every conceivable database driver if you're very unlikely to use it
1:23 they don't download all of them when you first install it.
1:27 So in order for some of the nice drag drop and other automatic things to happen
1:31 you need to make sure you do this once on your machine.
1:35 So I'm gonna collect download missing driver and everything is good.
1:40 I could come over here and give it a name and then morales over to this
1:43 file right there. But let's not go that path.
1:47 I just open that up one to show you the list of databases and two to
1:50 make sure the driver is installed.
1:51 I should be able to just drag this and drop it there,
1:54 wait for a moment and check it out.
1:56 We got a little one that means it found something that understood in here and then
2:00 it highlights our schema as well as some other server side sort of admin objects that
2:05 we don't care about. So we opened up and we got our tables,
2:08 check this out. Here's our packages,
2:10 here's the releases, maintainers, users downloads and so on and if we expand one
2:16 of these out, we've got our columns and these are they should map exactly over
2:22 to the columns that we had in SQLAlchemy over here.
2:26 We've got an idea that's a primary key and there you have it.
2:29 We've got the key symbol that's yellow,
2:31 that means primary key and we've got the vertical blue bar,
2:35 which means there's an index. The vertical blue bar with a dot means there's a
2:39 uniqueness constraint on that index and basically that's what a primary key as it has an
2:44 index. So you can query by it and it has to be unique because you
2:47 can't have two things with the same primary key.
2:49 We also have created date and last updated which have indexes but not uniqueness.
2:54 See down here we've got homepage we've got the author and so on.
3:00 Here's the one and only key that's the primary key on id.
3:03 And then these are all of the index is that we have here.
3:07 You can see some of them are just indexes and this one is unique.
3:11 So that's pretty cool. We got that and if we look at the other one
3:14 over here that we've been talking about the releases.
3:18 Again we have some similar things.
3:19 We've got an id
3:20 We've got our various things that we have an index on because we might query by
3:25 them. And then down here we have a foreign key relationships.
3:29 Notice this has a blue key.
3:31 So super cool. We can open up the key that's an ID.
3:34 And then there's the foreign key and the indexes as well.
3:38 So we'll be able to use this database exploration tool over here as our jumping off
3:44 point to dig into table schemas to indexes to queries and all sorts of stuff like
3:49 that looks like our PyCharm and our machine is set up and ready to work with SQLite.