Get startedGet started for free

Updating individual records

The update statement is very similar to an insert statement. For example, you can update all wages in the employees table as follows:

stmt = update(employees).values(wage=100.00)

The update statement also typically uses a where clause to help us determine what data to update. For example, to only update the record for the employee with ID 15, you would append the previous statement as follows:

stmt = stmt.where(employees.id == 15)

You'll be using the FIPS state code here, which is appropriated by the U.S. government to identify U.S. states and certain other associated areas.

For your convenience, the names of the tables and columns of interest in this exercise are: state_fact (Table), name (Column), and fips_state (Column).

This exercise is part of the course

Introduction to Databases in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Build a select statement: select_stmt
select_stmt = select([____]).where(____ == ____)

# Execute select_stmt and fetch the results
results = connection.____(____).____()

# Print the results of executing the select_stmt
print(____)

# Print the FIPS code for the first row of the result
print(results[0]['___'])
Edit and Run Code