|
Author
|
Message
|
|
Junior Member
|

02-09-2024
, 15:35
help with using sqlx
|
#1
|
Hello friends, let me show an example of what I want to do, the library I use is sqlx. I will run a query like this, I will give steamid, if that steamid is found, return; If not, it will insert. I leave the version I made with javascript below, I would appreciate it if you inform me.
const SteamID = '12345';
const Query = `SELECT * FROM players WHERE steam_id = '${SteamID}'`;
connection.query(Query, (error, results) => {
if (error) {
console.log(error.stack);
return;
}
if (results.length > 0) {
console.log('Steam ID found.');
} else {
const query2 = `INSERT INTO players (steam_id) VALUES ('${SteamID}')`;
connection.query(query2, (insertError, insertResults) => {
if (insertError) {
console.log(insertError.stack);
return;
}
}
|
|
|
|