From SQL to
Python: The Data
Structures Cheat
Sheet
Python Data Structures
*Dictionaries preserve insertion order in Python
3.7+
Lists [] = SELECT Results
A list is an ordered, mutable sequence that allows
duplicates. It’s your default choice for storing and
processing data like rows, query results, or column
values.
Common Operations
Lists are ordered and mutable (you can
change them)
Tuples () = Fixed Rows
A tuple is like a list, but immutable — you cannot
change its contents after creation.
Common Operations
Tuples are ordered but immutable
Sets {} = SELECT DISTINCT
Sets are unordered and automatically deduplicate
items. You can’t access them by index
Common Operations
Sets are unordered and do not allow duplicates.
Dictionaries {key: value} = Table Row
A dictionary is a collection of key-value pairs. Each
key maps to a value.
Common Operations
Dictionaries are unordered (prior to Python 3.7)
and mutable
SQL vs Python Structure Mapping