Jump to content

Recommended Posts

Posted

So I've spent the evening looking into the several MySQL UDFs across the forum, trying to understand how to use them, and I have failed horribly. Does anoybody know a good place to start? I'm just trying to do simple data storage and am only using the database at all for cross language compatibility.

Why cant there just be a simple function like

SendToDB( $value, $row, $cloumn, $table )
GetFromDB( $value, $row, $cloumn, $table )

All help appreciated :graduated:.

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Posted (edited)

For this simple DB purpose I recommend to use SQLite.

It's part of AutoIt and there are easy functions for working with DB data, see this example from Autoit's helppfile:

Good SQL help is here http://www.w3schools.com/sql/default.asp

#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $aResult, $iRows, $iColumns, $iRval

_SQLite_Startup ()
If @error > 0 Then
    MsgBox(16, "SQLite Error", "SQLite.dll Can't be Loaded!")
    Exit - 1
EndIf
_SQLite_Open () ; Open a :memory: database
If @error > 0 Then
    MsgBox(16, "SQLite Error", "Can't Load Database!")
    Exit - 1
EndIf

;Example Table
;   Name        | Age
;   -----------------------
;   Alice       | 43
;   Bob         | 28
;   Cindy       | 21

If Not _SQLite_Exec (-1, "CREATE TEMP TABLE persons (Name, Age);") = $SQLITE_OK Then _
        MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Alice','43');") = $SQLITE_OK Then _
        MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Bob','28');") = $SQLITE_OK Then _
        MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Cindy','21');") = $SQLITE_OK Then _
        MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())

; Query
$iRval = _SQLite_GetTable2d (-1, "SELECT * FROM persons;", $aResult, $iRows, $iColumns)
If $iRval = $SQLITE_OK Then
    _SQLite_Display2DResult($aResult)

;~   $aResult looks like this:
;~  
;~   Name   Age 
;~   Alice  43 
 
;~   Bob    28  
;~   Cindy 21  
;~
;~    If the dimensions would be switched in _SQLite_GetTable2d the result would look like this:
;~  
;~   Name  Alice Bob  Cindy 
;~   Age   43   28   21 
   

Else
    MsgBox(16, "SQLite Error: " $iRval, _SQLite_ErrMsg ())
EndIf

_SQLite_Close ()
_SQLite_Shutdown ()
Edited by Zedna
Posted

Im in the same boat, tried looking up using MySQL in autoit and it seems you need several addictional files and there is a big lack of help i.e. no helpfile or thread dead. Im just trying to have my 1500+ line script read a vaule from my webpages database.

muppet hands are so soft :)

Posted

I have used SQLite also and found it easy and fast. I also use the SQLite Manager add-on in Firefox to manipulate the DB without having to code the changes I want.

Posted

Hey guys, SqLite doesn't fit my purpose as it's local only. However I finally managed to figure out the mysql syntax. Thanks for the link zedna, it cleared alot of the fog from my eyes.

@russel

You interact with the mysql database through querys, which are like commands. Then you use another function to pull the result (depending on which UDF your using).

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...