I read a column's length in the code given below. Then, I have a list fakeNames
whose length is equal to the column's original length.
How can I replace the values of the original column person_names
with my list fakeNames
values? The changes should be reflected in the database.
import MySQLdb
# Connect
db = MySQLdb.connect(
host="abc.us-east-1.rds.amazonaws.com",
user="abc",
password="password",
)
cursor = db.cursor()
# Execute SQL select statement
cursor.execute("SELECT COUNT(person_names) FROM z3_table")
number_of_names = (cursor.fetchone()[0])
print(number_of_names)
fakeNames = []
# Commit your changes if writing
# In this case, we are only reading data
# db.commit()
# Close the connection
db.close()
This means that each value from the list fakeNames
should be in a different row.