LDB ( Little DataBase ) 1.0 Beta

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

LDB ( Little DataBase ) 1.0 Beta

Post by Droopy »

This library is for managing little database, with sort and search function.

I code it only with PB function ( without Api function )

If you find a bug, or error in my doc, please answer me

I provide a CHM help file and a Word file that described all command by function

Download the Library

Here's a test code

Code: Select all

; Test for the Ldb library ( Little Database )
; launch it in debug mode

; Initialize the Library
LdbInit()

; Create a new Database with 3 fields
LdbCreate("c:\Drivers.db","Birth Date,Name,Surname")

; Add one Record
LdbInsertRecord(-1)
; Write data to this record
LdbWrite(1,"1969") ; 1st field
LdbWrite(2,"Schumacher") ; 2nd field
LdbWrite(3,"Michey") ; 3rd field

; Add another Record
LdbInsertRecord(-1)
; Write data to this record
LdbWrite(1,"1980") ; 1st field
LdbWrite(2,"Button") ; 2nd field
LdbWrite(3,"Jenson") ; 3rd field

; Add another Record
LdbInsertRecord(-1)
; Write data to this record
LdbWrite(1,"1981") ; 1st field
LdbWrite(2,"Alonso") ; 2nd field
LdbWrite(3,"Fernando") ; 3rd field

; Add another Record
LdbInsertRecord(-1)
; Write data to this record
LdbWrite(1,"1971") ; 1st field
LdbWrite(2,"Villeneuve") ; 2nd field
LdbWrite(3,"Jacques") ; 3rd field

; Insert a record at 3rd position
LdbInsertRecord(3)
; Write data to this record
LdbWrite(1,"1975") ; 1st field
LdbWrite(2,"Schumacher") ; 2nd field
LdbWrite(3,"Ralph") ; 3rd field

; Move to 1st record cause bad surname
LdbSetPointer(1)
; Change Field 3 with good surname
LdbWrite(3,"Michael")

; Sort the database by field 1 ( Birth Date )
LdbSortNum(1)

; Show all drivers sorted by birth Date
Debug "Drivers sorted by birth date"
For n=1 To LdbCountRecord()
  LdbSetPointer(n)
  Debug LdbRead(1)+" "+LdbRead(2)+" "+LdbRead(3)
Next
Debug ""

; Sort the database by Drivers names
LdbSortAlpha(2,0)

; Show all drivers sorted by name
Debug "Drivers sorted by name"
For n=1 To LdbCountRecord()
  LdbSetPointer(n)
  Debug LdbRead(1)+" "+LdbRead(2)+" "+LdbRead(3)
Next
Debug ""

; Search all name = Schumacher
LdbSearchInit(2,"Schumacher",0)

; Show all drivers = Schumacher
Debug "Drivers with name = Schumacher"
Repeat
Champ=LdbSearch()
If Champ=0 : Break : EndIf ; if 0 --> search finished
LdbSetPointer(Champ)
Debug LdbRead(1)+" "+LdbRead(2)+" "+LdbRead(3)
ForEver
Debug ""

; Database Infos
Debug "Database Infos"
Debug "Number of fields "+Str(LdbCountField())
Debug "Name of field"
For n=1 To LdbCountField()
  Debug "Field n° "+Str(n)+" = "+LdbGetFieldName(n)
Next

Debug "Number of records "+Str(LdbCountRecord())

; Save Database to disk
LdbSaveDatabase()
; Close the Database
LdbCloseDatabase()
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Hi droopy!
i cant download your lib, the file is not reachable..

edit:
it seems that purestorage [purebasic.myftp.org] is not reachable..
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

I'm downloading the lib without problem.

AnybodyElse has the same problem ?
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

sry my fault my PeerGuardian blocked it.. Why?
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post by Bonne_den_kule »

thefool wrote:sry my fault my PeerGuardian blocked it.. Why?
The reason may be because the server don't send the filesize of the file
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

could be. it writes "Genuity" as the range.. [range is here the stuff to block. Othertimes it writes "fake fileservers block" etc]
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

Nice!!!!

This you test how much stable it is? Speed if database grows?

I was wanting something like this some time ago, thanks!!
ARGENTINA WORLD CHAMPION
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

forgot to test the lib :D

it looks pretty nice! it works without any problems. It seems
nice if you need a small database for your program!
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post by Beach »

thefool, are you still having issues downloading? Is my site being blocked by "peergaurd"??
-Beach
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

@beach: peerguardian 2 blocked it, but it has an ability to "Dont block http" so i turned that on and it worked. In PG2 log, it said "Genuity"
as bonne said "The reason may be because the server don't send the filesize of the file", that might be true.

info about peerguardian 2: http://www.methlabs.org/
But many users. 11,383 registered forum users, most online 472 users, so i would say its a widely known software. Also i didnt even find it on the internet i got it recommended by a friend :)

well it would be as bonne said, but why does it block the main page then?
zikitrake
Addict
Addict
Posts: 875
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Re: LDB ( Little DataBase ) 1.0 Beta

Post by zikitrake »

Droopy wrote:This library is for managing little database, with sort and search function.
Your lib will be very useful for me.

Thank you!
PB 6.21 beta, PureVision User
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post by Beach »

well it would be as bonne said, but why does it block the main page then?
I bet it is because of the redirect. "purebasic.myftp.org" redirects to my main web site. I just did this so I could move PureStorage easily if I needed to.

This database lib looks awsome... sorry to hijack the thread...
-Beach
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4790
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

This is good stuff

Post by Fangbeast »

Droopy, I'd like to use this with my Diabetes testing loggger and I have a question..

Is there any way to build in a search function (easily) that behaves like MySQL's?

Like: "=, Starts with, Ends With, Contains, <, >"

If not, I will have to start thinking (and that hurts!!)
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

Is there any way to build in a search function (easily) that behaves like MySQL's?

Like: "=, Starts with, Ends With, Contains, <, >"
= is the defaulf search
Contains = option #Everywhere

"Ends / < / > / Starts" I think it's not a big job
You have to add options ( #< #> #Start #Ends ) and in the search procedure treat this options


I provide the source code with the library
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4790
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Thanks Droopy

Post by Fangbeast »

I will give it a good read. Ever since I was diagnosed, I found a need for a small, local database like this one.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Post Reply