Effective PyCharm Transcripts
Chapter: Databases
Lecture: Adding database connections

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


Talk Python's Mastodon Michael Kennedy's Mastodon