Resource icon

Addon skript-db 0.2.0

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Let's say I want to subtract one value from the database from another, but I can't do that

does not work arithmetic calculations
You would have to grab the value, perform the operations you want to it, and then update the value in the database.
 
Doesn't work for me + 3

code_language.skript:
            execute "SELECT * FROM stats WHERE user = %player's name%" in {sql} and store output in {_statGGG::*}
            wait 2 ticks

            set {_statGGG} to {_statGGG::stol::*} + 3
            
            message "  %{_statGGG}%" to player
 
It won't lag the server using this addon since it's done asynchronously to avoid that.
if the MYSQL is at external place, if that server is disconnected, will it lag the server and if make a shop with skript-db MYSQL , will be player keep to get items from shop but the data will not be deducted because MYSQL is disconnect due to some issue ?
 
code_language.skript:
on script load:
  set {sql} to the database "mysql://185.227.81.30:3306/dylannl_status?user=dylannl_status&password=blegh&useSSL=false"
  execute "CREATE TABLE IF NOT EXISTS `test` (`name` varchar(255), `displayname` varchar(255))" in {sql}

Not working at all
 
if the MYSQL is at external place, if that server is disconnected, will it lag the server and if make a shop with skript-db MYSQL , will be player keep to get items from shop but the data will not be deducted because MYSQL is disconnect due to some issue ?
Database calls are made on a separate thread, so they will not hang your server.

As for your second issue, that depends on how your script is set up. As long as you give the player items after the database transaction is complete, you'll be fine.
 
Database calls are made on a separate thread, so they will not hang your server.

As for your second issue, that depends on how your script is set up. As long as you give the player items after the database transaction is complete, you'll be fine.
thanks
 
Could you make a addon for redis just like this one that allowed you to execute redis command from skript?

eg:
execute "set i 1" in {redis}
 
Lol's id is 7, I added the player "lol" using
code_language.skript:
"INSERT INTO users (id, player_uuid, username) values (7, 'a438454d-3859-3ed6-b009-7306ccb429b2', 'lol')"
and it worked, but when I try to get values from the ddb, it always return the column names istead of the result :/
My code:
code_language.skript:
command /hello:
   trigger:
       set {sql} to the database "jdbc:sqlite:/C:/Users/Valentin/Desktop/Jeux/Minecraft/Serveurs/SkriptCraft/plugins/Jobs/jobs.sqlite.db"
       execute "SELECT * FROM users WHERE username = 'lol'" in {sql} and store the result in {_output::*}
       loop {_output::*}:
           message "%loop-value%"
       message "%last database error%"
       message "%{_output::id}%"
output:
upload_2018-5-16_15-3-11.png
 
Lol's id is 7, I added the player "lol" using
code_language.skript:
"INSERT INTO users (id, player_uuid, username) values (7, 'a438454d-3859-3ed6-b009-7306ccb429b2', 'lol')"
and it worked, but when I try to get values from the ddb, it always return the column names istead of the result :/
My code:
code_language.skript:
command /hello:
   trigger:
       set {sql} to the database "jdbc:sqlite:/C:/Users/Valentin/Desktop/Jeux/Minecraft/Serveurs/SkriptCraft/plugins/Jobs/jobs.sqlite.db"
       execute "SELECT * FROM users WHERE username = 'lol'" in {sql} and store the result in {_output::*}
       loop {_output::*}:
           message "%loop-value%"
       message "%last database error%"
       message "%{_output::id}%"
output: View attachment 2135
You have to loop through {_output::<column>::*}, like {_output::id::*}
 
set {sql} to the database "mysql://127.0.0.1:3306/ferox?user=root&password=[password that works with mysql from the commandline]&useSSL=false" Any idea why this doesn't work with my mariadb instance?

it worked on my old server which used default mysql but this doesnt while mariadb is supposed to be a drop-in replacement.


com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
[doublepost=1527173435,1527101277][/doublepost]
set {sql} to the database "mysql://127.0.0.1:3306/ferox?user=root&password=[password that works with mysql from the commandline]&useSSL=false" Any idea why this doesn't work with my mariadb instance?

it worked on my old server which used default mysql but this doesnt while mariadb is supposed to be a drop-in replacement.


com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

edit: fixed! localhost doesn't work within docker containers and i had mariadb bound to localhost.
 
code_language.skript:
command /dbtest:
    trigger:
        execute "SELECT count(*)+1 FROM istatistik WHERE deger > (SELECT deger FROM istatistik WHERE isim = '%player%' and stat='sw.puan')" in {sql} and store the result in {siralamadeneme}
        wait 1 tick
        broadcast "%{siralamadeneme}%"

NOT WORK :C PLZ HELP
 
code_language.skript:
command /dbtest:
    trigger:
        execute "SELECT count(*)+1 FROM istatistik WHERE deger > (SELECT deger FROM istatistik WHERE isim = '%player%' and stat='sw.puan')" in {sql} and store the result in {siralamadeneme}
        wait 1 tick
        broadcast "%{siralamadeneme}%"

NOT WORK :C PLZ HELP
Use %player's name% or %player's uuid% instead of '%player%'
 
im getting
> [19:12:41 WARN]: [com.zaxxer.hikari.pool.PoolBase] HikariPool-1 - Failed to validate connection com.mysql.jdbc.JDBC4Connection@1f5d6436 (No operations allowed after connection closed.)

spammed in my console around every 5 minutes. Seems to be harmless but it does spam my logs (using mariadb, didn't have this on my old mysql instance and node)
 
any way to store lists? such as
code_language.skript:
{player.arrow-trails::*}
 
Last edited:
sync a list of materials that player has, {player.arrow-trails::*} = diamond_block,noteblock...
 
code_language.skript:
on skript load:
    set {sql} to the database "mysql://139.99.8.33:3306/mc44732?user=mc44732&password=***&useSSL=false"
    wait 1 tick
    execute "UPDATE Ekonomi SET `Bronze`=`Bronze`+1 WHERE Player=""CyanideToDeath""" in {sql}
No changes at all :/
Edited: Problem Fixed ... Sorry xD
 
Last edited: