Raised This Month: $ Target: $400
 0% 

help with using sqlx


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
mamistikfistik
Junior Member
Join Date: Feb 2024
Old 02-09-2024 , 15:35   help with using sqlx
Reply With Quote #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;
}
}
mamistikfistik is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode