![]() |
VOOZH | about |
Prerequisite: Python: MySQL Create Table
In this article, we are going to see how to Inserting data into a new column of an already existing table in MySQL using Python. Python allows the integration of a wide range of database servers with applications. A database interface is required to access a database from Python. MySQL Connector Python module is an API in python for communicating with a MySQL database.
Database table in use:
👁 ImageWe are going to use geeks(Database name) database and table describing the salary.
Approach:
ALTER TABLE person ADD salary int(20); UPDATE persons SET salary = '145000' where Emp_Id=12;
Before starting let do the same in SQL:
Step 1: Create a new column with alter command.
ALTER TABLE table_name ADD column_name datatype;👁 Image
Step 2: Insert data in a new column.
👁 ImageBelow is the full implementation in python:
Output:
👁 Image