Sign in to follow this  
Followers 0
pdsok

I want to make database type script

8 posts in this topic

Hi Guys, I have just got into simple scripts but I would like to create a database type thing where info is put into the gui via drop down box selections, dates and text input. these would then save to a file as entry1 entry2 etc etc. The saved files would then be searchable to pull up an entry containing matching text or dates or whatever.

Is this a viable idea or too over complicated etc. your thoughts would be welcomed.

I am not asking anyone to do this for me however I will no doubt drop by for advice once in a while :P

Unless of course someone has already done this and would like to give me the script :(

Thanks in advance for your help

--

PdSOK

Share this post


Link to post
Share on other sites



SQLite database is an option.

There is a collection of functions in SQLite.au3


When the words fail... music speaks

Share this post


Link to post
Share on other sites

SQLite database is an option.

There is a collection of functions in SQLite.au3

What I'm hoping to do would be completely stand alone to run on a std PC with no msoffice or database type programs installed.

The data would save to a file which is most likely a txt file or somesuch, similar to an ini file which can be made easily in AutoIt. It would then be searchable by all or each section but there will be multiple entries ie

entry1
data1=blahblah
data2=moreblahblah

entry2
data1=differentblahblah
data2=moredifferentblahblah

entry3
etc.....

it is stand alone as I do not have access to sql databases etc and I want it to be simple.

thanks

--

PdSOK

Share this post


Link to post
Share on other sites

What I'm hoping to do would be completely stand alone to run on a std PC with no msoffice or database type programs installed.

The data would save to a file which is most likely a txt file or somesuch, similar to an ini file which can be made easily in AutoIt. It would then be searchable by all or each section but there will be multiple entries ie

entry1
data1=blahblah
data2=moreblahblah

entry2
data1=differentblahblah
data2=moredifferentblahblah

entry3
etc.....

it is stand alone as I do not have access to sql databases etc and I want it to be simple.

thanks

--

PdSOK

SQLite database use SQLite.dll but is embeded in SQLite.dll.au3

What do you want look like an INI file.

Read in help file about Ini functions (IniRead,IniDelete, IniWrite, FileReadLine, IniReadSection, IniReadSectionNames, IniRenameSection, IniWriteSection)


When the words fail... music speaks

Share this post


Link to post
Share on other sites

Oh, didn't realise it was embedded I will look into that as an option I will also look at those you suggest.

I was thinking that the saved data would be saved in a file, like an ini file or whatever. But perhaps sql would be a better option so I will find out more about that.

Thanks for that Andreik,

I have to sign off now but i will be back !! :P)

--

PdSOK

Share this post


Link to post
Share on other sites

Oh, didn't realise it was embedded I will look into that as an option I will also look at those you suggest.

I was thinking that the saved data would be saved in a file, like an ini file or whatever. But perhaps sql would be a better option so I will find out more about that.

Thanks for that Andreik,

I have to sign off now but i will be back !! :P)

--

PdSOK

Another option is to create a file and put data in a certain form, using some separators.

The idea is to make it so that you can read, write, search and sort the data easily.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

You can also use the UDF I posted last week to simply write data into an SQLite database file, if you want a nice blend of the two...(INI and SQL).

http://www.autoitscript.com/forum/index.php?showtopic=82338

Otherwise, if you want to go ahead with writing a real database front-end, you're going to make extensive use of routines like the following:

#include <SQLite.au3>
#include <SQLite.dll.au3>
_SQLite_Startup()
_SQLite_Open(@ScriptDir&"\myDatabase.db")
_SQLite_Exec(-1,"CREATE TABLE IF NOT EXISTS 'MyTable' ('col1Name','col2Name','col3Name')")
_SQLite_Exec(-1,"INSERT INTO 'MyTable' VALUES ('key1','data1','more info')")
_SQLite_Exec(-1,"INSERT INTO 'MyTable' VALUES ('key2','more data','more info...again')")
_SQLite_Exec(-1,"INSERT INTO 'MyTable' VALUES ('another key; see?','yet more data','search for me!')")
Local $aResult,$iRows,$iCols,$searchStr=InputBox("Search for:","Please enter the string you wish to search for:","")

If _SQLite_GetTable2d(-1,"SELECT col1Name FROM MyTable WHERE col1Name Like '%"&$searchStr&"%' UNION SELECT col1Name FROM MyTable WHERE col2Name LIKE '%"&$searchStr&"%' UNION SELECT col1Name FROM MyTable WHERE col3Name LIKE '%"&$searchStr&"%' ORDER BY col1Name",$aResult,$iRows,$iCols) <> $SQLite_OK OR $iRows=0 Then

  MsgBox(0,"No results","No results were found.  Deep search will now be performed:")

  If _SQLite_GetTable2d(-1,"SELECT col1Name FROM MyTable WHERE col1Name Like '%"&StringReplace($searchStr," ","%")&"%' UNION SELECT col1Name FROM MyTable WHERE col2Name LIKE '%"&StringReplace($searchStr," ","%")&"%' UNION SELECT col1Name FROM MyTable WHERE col3Name LIKE '%"&StringReplace($searchStr," ","%")&"%' ORDER BY col1Name",$aResult,$iRows,$iCols) <> $SQLite_OK OR $iRows=0 Then

    MsgBox(0,"No resluts","I was still unable to find results...sorry!")
  Else
    Local $tmp=""
    For $i=1 To $iRows
      $tmp&=$aResult[$i][0]&@CRLF
    Next
    MsgBox(0,"Deep search results:",$tmp)
  EndIf
Else
  Local $tmp=""
  For $i=1 To $iRows
    $tmp&=$aResult[$i][0]&@CRLF
  Next
  MsgBox(0,"Results:",$tmp)
EndIf
_SQLite_Close()
_SQLite_Shutdown()
So in this example, it searches first for your exact string in any of the three columns. If it can't find it, it will perform what I call a "deep search"...that is, anywhere there's a space, it will allow any number of characters between the two strings you gave it.

So, for instance, if you were to search for 'searc me', it would first not find anything, but in the deep search, it will find "another key;see?", because in column 3 of that row, there's the string "search for me!"...so it skipped the h, space, for and another space between the "searc" and "me". If you just searched for 'searc' however, it would find it the first time through.

If you wanted, you could also make a really deep search, which would be adding a % character (SQL wildcard character) between EVERY character of the string that's being searched for...that would find all results with all of the characters you entered, in the same order, but not necessarily in any particular word grouping. That tends to return a large number of results.

You could also limit the results more than my first routine above...if you leave the first % out of the

where col1Name Like '%"&$searchStr&"%'
bits, it will only search for the string you give it at the BEGINNING of the data...so searching for "me" would not return any results because the only place that "me" occurs is proceeded by "search for ".

Of course, to make it usable for your purposes, you'll have to replace the

_SQLite_Exec(-1,"INSERT
lines with something that will actually allow YOU to input data though :(

I hope that makes sense :P

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

OK I've took a quick look at that and to be frank James, at the moment it makes little sense.

however I will now have a play using sql and ini write/read etc and see how i get on.

Unfortunately I am not very experienced as yet but this will be my learning project so thanks for the help.

--

PdSOK

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  
Followers 0