PDA

View Full Version : How do change data in a database?



Felicityges
08-25-2022, 07:18 AM
i have list of list

listofplayers = [[player1, 5,1,300,100],[player11, 10,5,650,150],[player23, 17,6,1100,1050]]

and i have a database

player, win, lost, moneywin, moneylost
player1, 3 , 0 , 250 , 50
player2 ...
player3 ...
...

how do i update my database with the new info in my listofplayers? Like this:

player, win, lost, moneywin, moneylost
player1, 5, 1, 300, 100,
player2 ...
player3 ...
player11, 10, 5, 650, 150
player23, 17, 6, 1100, 1050

i tried different things but i just can't find the resources

here's my best attempt:

1
2
3
4
5
6
7
8

for i in listofplayers
for j, k in db.iterrows():
if i[0] == j['player']:
index = db.index[db[j]==k].tolist()
db.at[index,j] = i[y]
index = []
y+=1

as you can see i'm having troubles...
this is my very first attempt at pandas and i'm still new to programming

Ralf Pi
08-30-2022, 05:33 AM
You will need to use SQL (database query language) and other complicated programs.

Evonne Millier
08-30-2022, 07:51 AM
Do you know how to work with SQL? Transact-SQL and SQL Server Management Studio are the tools to change data in a database. You will need to access the data editor then select the commands to replace for edit, tap quick find next to find and replace. There are many tutorials on youtube and mysql.com that can serve as a guide for you. In case, you are lack data for your database read about the features of B2B data providers (https://www.globaldatabase.com/top-10-features-of-data-providers). Shortly, data providers will enrich your database with reliable information.
Good luck!

Rostiksr
09-01-2022, 05:40 AM
You must have a certain level of knowledge in working with SQL. Otherwise, you will need the help of a specialist. In any case, I recommend making backups and using a monitoring service https://www.host-tracker.com/en/ to track the performance of the project after making changes.