Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Starting With DuckDB and Python (Summary)

You’ve had an overview of DuckDB, and now have the knowledge and skills necessary to get started using it in your code.

In this video course, you’ve learned how to:

  • Create DuckDB databases from data files
  • Verify your data files have been read correctly
  • Query the database using Structured Query Language (SQL)
  • Query the database using DuckDB’s Python Application Programming Interface (API)
  • Access the database concurrently
  • Use DuckDB data in a Python environment

Resources Linked in This Lesson

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

00:00 In the previous lesson, I showed you how to integrate a Python function into the DuckDB namespace, as well as how to get pandas and Polars DataFrames from your query results.

00:10 This is the last lesson, and in it I’ll summarize the course and point you at other resources.

00:16 DuckDB is an analytics-focused database that lets you use SQL mechanisms where you might otherwise use a DataFrame. DuckDB supports both in-memory and more traditional file-based operations, and like any relational database, uses SQL.

00:31 It also has API entry points for a variety of languages, including, of course, Python. When you query DuckDB in Python, it returns relation objects. You can query a relation object like a DataFrame to get information.

00:45 You can get at the rows of the results from inside of it, or you can use it to create further queries. In addition to all the typical relational database operations, DuckDB also allows you to hook Python functions into its calling space, giving you even more flexibility in producing your results.

01:05 The DuckDB documentation is quite comprehensive, if a little messy. Due to the fact that it supports many programming languages, it’s divided up into pieces.

01:14 There are generic SQL-based docs as well as language-specific API docs. When you’re searching, you might get one when you want the other, but once you’ve used them enough, it’ll all make sense.

01:26 If you want to learn more about SQL, there are plenty of good sources out there on the web. This link is to the Khan Academy and is part of one of their larger courses on JavaScript, but the SQL bit is good.

01:38 I won’t tell anyone you went to a JavaScript site if you don’t.

01:43 Real Python has even more content related to this topic. First off, this tutorial introduces you to the many different ways you can interact with SQL databases through Python,

01:53 and this one covers the SQL injection problem I mentioned briefly and what to do about it. If you want to learn more about DataFrames, this pandas course and tutorial or this Polars course and tutorial might be of interest.

02:07 The Polars course is one of mine, and so it probably contains bear puns instead of duck ones. Variety’s the spice of life after all. You know, including this sentence, I’ve said duck eight times in this lesson without pausing once for a silly sound effect.

02:23 That’s a tremendous amount of self-control if you ask me.

02:29 Thanks for your attention. I hope you enjoyed the course.

Become a Member to join the conversation.