Raised This Month: $51 Target: $400
 12% 

[Tool]SQLQueries


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Timiditas
Senior Member
Join Date: Apr 2009
Plugin ID:
1880
Plugin Version:
1.0.1
Plugin Category:
Admin Commands
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Dispatch SQL queries via console or even chat
    Old 08-14-2010 , 09:38   [Tool]SQLQueries
    Reply With Quote #1

    Dispatch SQL queries via Serverconsole, Clientconsole, Chat or RCON

    Available commands can only be used by root admins (flag Z) if dispatched from a client.

    sql_connect_sqlite
    connect to local sqlite database
    usage: sql_connect_sqlite <\"dbname\"> <CreateIfNonExistant - 1|0 - default:0>

    sql_connect_section
    connect to db listed in configs/databases.cfg
    usage: sql_connect_section <\"databases.cfg section\">

    sql_connect_custom
    connect with custom settings
    usage: sql_connect_custom <dbtype(sqlite|mysql)> <\"hostname/ip\"> <\"database\"> <\"username\"> <\"password\"> <\"port\">

    sql_disconnect
    disconnect
    usage: sql_disconnect (no arguments)

    sql_query
    dispatch sql query
    usage: sql_query "query string"

    Only the first result set will be returned if there are more than one.
    The command loops through all rows and columns and prints them out.
    You should avoid queries with big resultsets, as this WILL lag the server because of a buttload of string concatenation.
    You can put "sql_connect*whatever*" to your servers autoexec.cfg if you like, so you can quickly send queries to your main db whenever you feel like.
    A typical console printout while using this plugin might look like this:

    Code:
    ] sql_connect_sqlite dignatio
    Can't select character set (SET NAMES 'utf8')
    DatabaseInit SQLLITE (CONNECTED)
    SQLITE_VERSION()
    ----------------
    3.5.1
    Tables
    ------
    Accuracy
    Map
    Player
    countrylist
    data
    
    ] sql_query "SELECT name,points FROM Player"
    NAME|POINTS
    -----------
    Timiditas|44
    
    ] sql_query "update Player set points = 0 where name = 'Timiditas'"
    Affected rows: 1
    
    ] sql_disconnect
    Plugin updated, fixed runtime error on queries with no resultset (UPDATE, DELETE,INSERT...)
    Attached Files
    File Type: sp Get Plugin or Get Source (SQLQueries.sp - 1017 views - 9.1 KB)
    __________________


    Last edited by Timiditas; 04-10-2011 at 06:08.
    Timiditas is offline
    DarkEnergy
    SourceMod Donor
    Join Date: Apr 2008
    Location: Georgia Tech, MSECE
    Old 08-14-2010 , 11:31   Re: [Tool]SQLQueries
    Reply With Quote #2

    very nice
    buttload of string concats are fine
    __________________
    War3:Source Developer
    "Your CPU is just a bunch of Muxes"
    DarkEnergy is offline
    berni
    SourceMod Plugin Approver
    Join Date: May 2007
    Location: Austria
    Old 01-25-2011 , 17:34   Re: [Tool]SQLQueries
    Reply With Quote #3

    Version cvars require the CVAR FLAG FCVAR_NOTIFY.

    Will be approved when fixed.
    __________________
    Why reinvent the wheel ? Download smlib with over 350 useful functions.

    When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
    powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
    berni is offline
    Timiditas
    Senior Member
    Join Date: Apr 2009
    Old 04-10-2011 , 06:10   Re: [Tool]SQLQueries
    Reply With Quote #4

    FCVAR_NOTIFY added to version convar
    __________________

    Timiditas is offline
    theY4Kman
    Join Date: Jun 2007
    Location: Yak
    Old 07-07-2012 , 19:12   Re: [Tool]SQLQueries
    Reply With Quote #5

    I guess this never did get approved In any case, I found it quite useful. I modified it to chunk the output of large rows, such as those returned by "SHOW CREATE TABLE".

    Attached Files
    File Type: sp Get Plugin or Get Source (SQLQueries.sp - 1032 views - 11.6 KB)
    __________________
    http://y4kstudios.com
    Is that loud enough? Oh, while I have you, check out Viper.
    theY4Kman is offline
    Send a message via ICQ to theY4Kman Send a message via AIM to theY4Kman Send a message via MSN to theY4Kman Send a message via Yahoo to theY4Kman Send a message via Skype™ to theY4Kman
    Reply



    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 18:52.


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