Total players online: 1



Take the Tour | Site Map

It is currently Thu Dec 14, 2017 8:34 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Aug 25, 2016 11:14 am 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 08/14/2003 19:12
Posts: 1446

Its not tested but at a glance it seems to be working. Needs a way to compact the database and a file based index rather than one in memory that is rebuilt everytime the database is opened. Lua choked on some data I tried to load so I looked for a solution. sqlite3 was working good but I think I will prefer using lua tables. Comments? Want to give it a try?

The format is basically either a 255 or 1 byte followed by a stringized table followed by a '\n'. The records beginning with a 1 byte code are valid and the records beginning with a 255 byte code are 'deleted'. All the code below is just about using it.

EDIT: Unless I need SQL robustness like thread safety this is going to be much easier and faster to use. I really like that the database is smaller even tho every value has its key name attached to it and there is no pre-defined pattern to what can be stored.

Code:
  1. --[[
  2.         Author: Kal In Ex
  3.         Date: August 25-27, 2016
  4.         Purpose: lua database
  5.  
  6. -- Work in progress so removed from post


Sample database: the 1 bytes codes do not show up in the code below

Code:
  1. -{"hello world",74,"goodbye",[0]="zero",}
  2. +{1,2,3,4,5,6,}
  3. +{1,2,3,4,5,6,}
  4. +{1,2,3,4,5,6,}
  5. +{"a","b","c","d",}

_________________
EasyUO User Since: November 2001
Registered This User On: April2, 2002

Kal In Ex\'s Script Library
:roll: I am INCOGNITO! :roll:


Last edited by Kal In Ex on Sat Aug 27, 2016 10:37 am, edited 8 times in total.

Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Thu Aug 25, 2016 12:52 pm 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 08/14/2003 19:12
Posts: 1446

Has issues I am trying to use it now... nested tables are not working...
EDIT: I may have that fixed now.

_________________
EasyUO User Since: November 2001
Registered This User On: April2, 2002

Kal In Ex\'s Script Library
:roll: I am INCOGNITO! :roll:


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Thu Aug 25, 2016 5:41 pm 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 08/14/2003 19:12
Posts: 1446

Its much faster now and the openDatabase function accepts another parameter that effects the order that key:value pairs are written to file. for example openDatabase('testdb',{'id','name','color'}) will cause all future record saves to write those keys first and in that order. All keys still get written this is just for priority since the database can be loaded into an editor this will make looking at some data sets much easier. Existing records saved in the database are not effected.

_________________
EasyUO User Since: November 2001
Registered This User On: April2, 2002

Kal In Ex\'s Script Library
:roll: I am INCOGNITO! :roll:


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sat Aug 27, 2016 9:47 am 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 08/14/2003 19:12
Posts: 1446

kind of an after thought but I think I am going to use +- instead of a 1 or 255 byte code to show if the record is deleted or not.

_________________
EasyUO User Since: November 2001
Registered This User On: April2, 2002

Kal In Ex\'s Script Library
:roll: I am INCOGNITO! :roll:


Top
  ProfileShow poster's scripts in the public script library 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Hosted by CalWeb Internet Services, Inc.