How to Update all the Values of a Specific Column of SQLite Table using Python ? Last Updated : 28 Apr, 2021 Comments Improve Suggest changes Like Article Like Report In this article, we are going to update all the values of a specific column of a given SQLite table using Python. In order to update all the columns of a particular table in SQL, we use the UPDATE query. The UPDATE statement in SQL is used to update the data of an existing table in the database. We can update single columns as well as multiple columns using the UPDATE statement as per our requirement. Syntax: UPDATE table_name SET column_name=value; We are going to create a table and then perform update operations in it. Python3 # importing sqlite module import sqlite3 # create connection to the database my_database connection = sqlite3.connect('my_database.db') # create table named address of customers # with 4 columns id,name age and address connection.execute('''CREATE TABLE ship (ship_id INT, ship_name \ TEXT NOT NULL, ship_destination CHAR(50) NOT NULL); ''') print("Ship table created successfully") # close the connection connection.close() Output: Ship table created successfully Example 1: Python program to insert records and perform update queries. Here we update all data in the ship_name column to manoji. Python3 # import sqlite module database import sqlite3 # create connection to the database # my_database connection = sqlite3.connect('my_database.db') # insert query to insert values connection.execute("INSERT INTO ship VALUES (1, 'tata-hitachi','noida' )") connection.execute("INSERT INTO ship VALUES (2, 'tata-mumbai','mumbai' )") connection.execute("INSERT INTO ship VALUES (3, 'tata-express','hyderabad' )") # query to display all data in the table cursor = connection.execute("SELECT * from ship") print("before updation") # display row by row for row in cursor: print(row) # query to update all data in ship_name # column to manoji connection.execute("UPDATE ship set ship_name='manoji'") print("After updation") # display row by row cursor = connection.execute("SELECT * from ship") for row in cursor: print(row) # close the connection connection.close() Output: Example 2: In this program, we first insert data then update all data in ship_address to Delhi in the same table. Python3 # import sqlite module database import sqlite3 # create connection to the database # my_database connection = sqlite3.connect('my_database.db') # insert query to insert values connection.execute("INSERT INTO ship VALUES (1, 'tata-hitachi','noida' )") connection.execute("INSERT INTO ship VALUES (2, 'tata-mumbai','mumbai' )") connection.execute("INSERT INTO ship VALUES (3, 'tata-express','hyderabad' )") # query to display all data in the table cursor = connection.execute("SELECT * from ship") print("before updation of ship address") # display row by row for row in cursor: print(row) # query to update all data in ship_address connection.execute("UPDATE ship set ship_destination='delhi'") print("After updation of ship address") # display row by row cursor = connection.execute("SELECT * from ship") for row in cursor: print(row) # close the connection connection.close() Output: Comment More info M manojkumarreddymallidi Follow Improve Article Tags : Python Python-SQLite Explore Python FundamentalsPython Introduction 3 min read Input and Output in Python 4 min read Python Variables 5 min read Python Operators 5 min read Python Keywords 2 min read Python Data Types 7 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 6 min read Python Functions 5 min read Recursion in Python 4 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 4 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 2 min read Python MySQL 9 min read Python Packages 12 min read Python Modules 7 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 6 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 15+ min read StatsModel Library- Tutorial 4 min read Learning Model Building in Scikit-learn 8 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 7 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 7 min read Python | Build a REST API using Flask 3 min read How to Create a basic API using Django Rest Framework ? 4 min read Python PracticePython Quiz 3 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like