1. 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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Addon skript-db 0.2.0

Sensible SQL support for Skript

  1. btk5h

    Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    154
    Likes Received:
    155
    I think I had a fix, but I forgot to push a new version. I'll push one this weekend.
     
    • Like Like x 1
  2. SmilingSlimeGuy

    Joined:
    Jan 30, 2017
    Messages:
    7
    Likes Received:
    0
    Am having this error:

    You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''discord' SET 'coins' = '10' WHERE 'id' = 6' at line 1

    When using this code:

    execute "UPDATE 'discord' SET 'coins' = '10' WHERE 'id' = %{_r::id::1}%" in {sql}

    Any idea as to what is causing this?
    --- Double Post Merged, Jan 22, 2018, Original Post Date: Jan 20, 2018 ---
    Bump
     
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,049
    Likes Received:
    145
  4. Spartan9802

    Spartan9802 Member

    Joined:
    Jan 26, 2017
    Messages:
    158
    Likes Received:
    8
    Hello,
    Can you help me with my mistake?
    Code (Skript):
    1. set {test} to the database "jdbc:sqlite:/home/minecraft/multicraft/servers/WorldCube_Serveur/plugins/Landlord/Landlord.db"
    Code (Skript):
    1. HikariPool-1 - Starting...
    2. 26.01 12:51:57 [Server] INFO HikariPool-1 - Driver does not support get/set network timeout for connections. (org.sqlite.Conn.getNetworkTimeout()I)
    3. 26.01 12:51:57 [Server] ERROR HikariPool-1 - Failed to execute isValid() for connection, configure connection test query (org.sqlite.Conn.isValid(I)Z).
    4. 26.01 12:51:57 [Server] WARN java.util.concurrent.CompletionException: java.lang.AbstractMethodError: org.sqlite.Conn.isValid(I)Z
    5. 26.01 12:51:57 [Server] WARN at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273)
    6. 26.01 12:51:57 [Server] WARN at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280)
    7. 26.01 12:51:57 [Server] WARN at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1592)
    8. 26.01 12:51:57 [Server] WARN at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    9. 26.01 12:51:57 [Server] WARN at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    10. 26.01 12:51:57 [Server] WARN at java.lang.Thread.run(Thread.java:748)
    11. 26.01 12:51:57 [Server] WARN Caused by: java.lang.AbstractMethodError: org.sqlite.Conn.isValid(I)Z
    12. 26.01 12:51:57 [Server] WARN at com.zaxxer.hikari.pool.PoolBase.checkDriverSupport(PoolBase.java:434)
    13. 26.01 12:51:57 [Server] WARN at com.zaxxer.hikari.pool.PoolBase.setupConnection(PoolBase.java:405)
    14. 26.01 12:51:57 [Server] WARN at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:363)
    15. 26.01 12:51:57 [Server] WARN at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
    16. 26.01 12:51:57 [Server] WARN at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:443)
    17. 26.01 12:51:57 [Server] WARN at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:514)
    18. 26.01 12:51:57 [Server] WARN at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:111)
    19. 26.01 12:51:57 [Server] WARN at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:97)
    20. 26.01 12:51:57 [Server] WARN at com.btk5h.skriptdb.skript.EffExecuteStatement.executeStatement(EffExecuteStatement.java:104)
    21. 26.01 12:51:57 [Server] WARN at com.btk5h.skriptdb.skript.EffExecuteStatement.lambda$execute$1(EffExecuteStatement.java:72)
    22. 26.01 12:51:57 [Server] WARN at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
    23. 26.01 12:51:57 [Server] WARN ... 3 more
     
  5. C

    CookieST Member

    Joined:
    Feb 10, 2017
    Messages:
    4
    Likes Received:
    0
    Code (Skript):
    1. [15:13:15] [pool-10-thread-6/WARN]: [com.zaxxer.hikari.pool.PoolBase] HikariPool-1 - Failed to validate connection com.mysql.jdbc.JDBC4Connection@49bcbb3 (No operations allowed after connection closed.)
    How do I keep the addon connected to the database?
    • Is it possible to check if the connection is active?
    • Is it possible to autoreconnect?
    • Is it possible to just keep it connected?
     
  6. btk5h

    Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    154
    Likes Received:
    155
    This isn't possible yet. I'll add autoreconnect to a future version.
     
  7. C

    CookieST Member

    Joined:
    Feb 10, 2017
    Messages:
    4
    Likes Received:
    0
    While you are at it you could add a method for checking if a connection is active... Then if not you could just connect using the existing method.
     
  8. mel_instagibson

    Joined:
    Feb 4, 2017
    Messages:
    71
    Likes Received:
    4
    im having troubles using variables in queries it seems like a bug but i'm not sure, here is what im trying to do:

    Code (Skript):
    1. command /equip:
    2.         permission: *
    3.         trigger:
    4.                 set {_u} to "ff310bf1-64c6-4f9f-9fc9-bf3fbd6bd959" #<- this should actually be uuid of player, i typed it out for testing
    5.                 send "%{_u}%"
    6.                 execute "SELECT slot FROM inventory.`%{_u}%`" in {db} and store output in {_c::*}
    7.                 send "%{_c::*}%"
    I also tried variations with set {_u} to "inventory.ff310bf1-64c6-4f9f-9fc9-bf3fbd6bd959" and with or without the "`" but nothing worked besides this:

    Code (Skript):
    1. command /equip:
    2.         permission: *
    3.         trigger:
    4.                 set {_u} to "ff310bf1-64c6-4f9f-9fc9-bf3fbd6bd959" #<- this should actually be uuid of player, i typed it out for testing
    5.                 send "%{_u}%"
    6.                 execute "SELECT slot FROM inventory.`f310bf1-64c6-4f9f-9fc9-bf3fbd6bd959`" in {db} and store output in {_c::*}
    7.                 send "%{_c::*}%"
    Edit:
    it seems to work if i use the "execute unsafe" expression, if i don't and try to use the same skript i get the error "Parameter index out of range (1 > number of parameters, which is 0)"

    after googling a bit i haven't really found anything i can do about this error on my end and it might be a driver issue, im using mariadb.
     
    #48 mel_instagibson, Feb 21, 2018
    Last edited: Feb 21, 2018
  9. btk5h

    Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    154
    Likes Received:
    155
    I would suggest restructuring your database as creating a separate table for each user is not a common practice. However, if you really need this, you can use unsafe {_u} instead of {_u}.
     
    • Useful Useful x 1
  10. mel_instagibson

    Joined:
    Feb 4, 2017
    Messages:
    71
    Likes Received:
    4
    oh, you already replied ^^

    yea having uuids as table names seems to be a kinda troublesome, i might have to restructure but for now ill use the unsafe workaround

    does this only happen due to the format of uuids?
     
  11. x

    xbxy Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    170
    Likes Received:
    8
    There was a mistake.
    Code (Text):
    1.  
    2.         set {sql} to the database "mysql://localhost:3306/k8_cf?user=root&password=XBXY&useSSL=false"
    3.         execute "select * from playerpoints22 where id = 10880" in {sql} and store the result in {output::*}
    4.  
    [10:44:25 WARN]: java.util.concurrent.CompletionException: java.lang.NoClassDefFoundError: com/zaxxer/hikari/pool/HikariPool
    [10:44:25 WARN]: at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273)
    [10:44:25 WARN]: at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280)
    [10:44:25 WARN]: at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1592)
    [10:44:25 WARN]: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    [10:44:25 WARN]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    [10:44:25 WARN]: at java.lang.Thread.run(Thread.java:748)
    [10:44:25 WARN]: Caused by: java.lang.NoClassDefFoundError: com/zaxxer/hikari/pool/HikariPool
    [10:44:25 WARN]: at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:97)
    [10:44:25 WARN]: at com.btk5h.skriptdb.skript.EffExecuteStatement.executeStatement(EffExecuteStatement.java:104)
    [10:44:25 WARN]: at com.btk5h.skriptdb.skript.EffExecuteStatement.lambda$execute$1(EffExecuteStatement.java:72)
    [10:44:25 WARN]: at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
    [10:44:25 WARN]: ... 3 more
     
  12. h

    helomi Member

    Joined:
    Feb 9, 2017
    Messages:
    18
    Likes Received:
    0
    Do you have some idea?
    1. 2. 4. 6. Did not work 3. 5. Worked
    Server version
    Nevest spigot 1.8.8
    Skript Last version
    Skript-DB Last version
    Skellet Last version
    1.
    Code (Text):
    1. execute "INSERT INTO test (`username`) VALUES ('%player%')" in {sql}
    2.
    Code (Text):
    1. execute "INSERT INTO test (`username`) VALUES (%player%)" in {sql}
    3.
    Code (Text):
    1. execute "INSERT INTO test (`username`) VALUES ('%%player%%')" in {sql}
    4.
    Code (Text):
    1. execute "INSERT INTO test (`username`) VALUES (%%player%%)" in {sql}
    5.
    Code (Text):
    1. execute "INSERT INTO test (`username`) VALUES ('test')" in {sql}
    6.
    Code (Text):
    1. execute "INSERT INTO test (`username`) VALUES (test)" in {sql}
    My mysql table settings

    [​IMG]
     
  13. btk5h

    Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    154
    Likes Received:
    155
    I don't believe Java will replace table names in prepared statements.
    Player isn't a SQL type. Use player's name or player's uuid instead of player.
     
  14. m

    mccrafter1212 Member

    Joined:
    Jul 16, 2017
    Messages:
    11
    Likes Received:
    0
    Code (Skript):
    1.  
    2. execute "SELECT * FROM test WHERE username = '%player%'" in {sql} and store the result in {output2::*}
    3. broadcast "%{output::gold}%" # Should broadcast 25 instead broadcasts <none>
    4.  
    Can anyone help? It only broadcasts <none>.
     
  15. Snow-Pyon

    Moderator Resource Staff

    Joined:
    Jan 25, 2017
    Messages:
    1,233
    Likes Received:
    172
    Medals:
    player != player's name.
     
  16. m

    mccrafter1212 Member

    Joined:
    Jul 16, 2017
    Messages:
    11
    Likes Received:
    0
    @Snow-Pyon I'm confused by your reply... %player% always gives the username of the player. I'm already in the DB with data so it should broadcast correctly.
     
    #56 mccrafter1212, Apr 7, 2018
    Last edited: Apr 7, 2018
  17. btk5h

    Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    154
    Likes Received:
    155
    Code (Skript):
    1. execute "SELECT * FROM test WHERE username=%player's name%" in {sql} and store the result in {output2::*}
    Do not surround the embedded expression with quotes. Also, you must explicitly use player's name.
     
    • Like Like x 1
  18. I

    IvanFakov Member

    Joined:
    Apr 13, 2018
    Messages:
    3
    Likes Received:
    0
    Can't understand how to add variables from the database

    set {kdr} to {stat::deads::*} + 1

    Not working
     
  19. btk5h

    Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    154
    Likes Received:
    155
    I need more context to tell you what's going on.
     
  20. I

    IvanFakov Member

    Joined:
    Apr 13, 2018
    Messages:
    3
    Likes Received:
    0
    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
     
Loading...