Jump to content
Sign in to follow this  
jorgeng

tcp with database

Recommended Posts

jorgeng

Hello!

I have managed to do a tcp send.

I was happy but then get new info that for every tcp send i will have to store information about customer and data sent in a database, table.

I have read help-file that autoit supports sql commands but for what i can see there is only possible to have a table in memory.

Is it possible to create an sql table and to insert of rows, update from autoit and store it on disk?

I'm thinking of sqlite, see example:

#include <SQLite.au3>

#include <SQLite.dll.au3>

Local $hQuery, $aRow, $sMsg

_SQLite_Startup ()

_SQLite_Open () ; open :memory: Database

_SQLite_Exec (-1, "CREATE TABLE aTest (a,b,c);") ; CREATE a Table

_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','World');") ; INSERT Data

_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('b','3',' ');") ; INSERT Data

_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('a','1','Hello');") ; INSERT Data

_SQlite_Query (-1, "SELECT c FROM aTest ORDER BY a;", $hQuery) ; the query

While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK

$sMsg &= $aRow[0]

WEnd

;_SQLite_Exec (-1, "DROP TABLE aTest;") ; Remove the table

MsgBox(0,"SQLite","Get Data using a Query : " & $sMsg )

_SQLite_Close()

_SQLite_Shutdown()

;~ Output:

;~

;~ Hello World

:)

Edited by jorgeng

Share this post


Link to post
Share on other sites
ChrisL

Hello!

I have managed to do a tcp send.

I was happy but then get new info that for every tcp send i will have to store information about customer and data sent in a database, table.

I have read help-file that autoit supports sql commands but for what i can see there is only possible to have a table in memory.

Is it possible to create an sql table and to insert of rows, update from autoit and store it on disk?

I'm thinking of sqlite, see example:

#include <SQLite.au3>

#include <SQLite.dll.au3>

Local $hQuery, $aRow, $sMsg

_SQLite_Startup ()

_SQLite_Open () ; open :memory: Database

_SQLite_Exec (-1, "CREATE TABLE aTest (a,b,c);") ; CREATE a Table

_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','World');") ; INSERT Data

_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('b','3',' ');") ; INSERT Data

_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('a','1','Hello');") ; INSERT Data

_SQlite_Query (-1, "SELECT c FROM aTest ORDER BY a;", $hQuery) ; the query

While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK

$sMsg &= $aRow[0]

WEnd

;_SQLite_Exec (-1, "DROP TABLE aTest;") ; Remove the table

MsgBox(0,"SQLite","Get Data using a Query : " & $sMsg )

_SQLite_Close()

_SQLite_Shutdown()

;~ Output:

;~

;~ Hello World

:)

_SQLite_Open ("c:\MyTable.db") will open it as a file

Share this post


Link to post
Share on other sites
ptrex

@jorgeng

A good approach might be the you open a "In Memory DB" AND a "Physical DB"

The in memory DB can be used to keep track of who is connected over TCP.

Also you can write back the info who logged on and what query was run, etc.

The Query of course should be processed against the physical DB.

Once the query is executed properly you can delete it back from the In Memory DB.

This way the In Memory DB functions as a Queue and logging DB.

I hope this can help.

regards

ptrex

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.