Monkey Database

Monkey Forums/Monkey Programming/Monkey Database

Soap(Posted 2011) [#1]
It's pretty silly that monkey doesn't have built in database capabilities. What are some possible solutions and what platforms would they perform on?


Warpy(Posted 2011) [#2]
SQLite would probably work on all platforms. There's even a javascript API.


FlameDuck(Posted 2011) [#3]
Alternatively, use something like CouchDB.


Soap(Posted 2011) [#4]
Hey warpy, for SQLite is it only webbased or could I make a desktop app with it?


muddy_shoes(Posted 2011) [#5]
If anything, SQLite is best suited for single-user desktop apps and not the best choice for multi-user and client-server situations. Considering the state of the WebSQL spec and implementations, some sort of abstracted layer that allows different DB backends would probably be needed for a database module that works across all Monkey targets.


Soap(Posted 2011) [#6]
I want to start with a desktop application that is cross platform. What would be the best free option for this?


Cartman(Posted 2011) [#7]
I've been using SQLite on Blitzmax using Brucey's Database module. Works like a charm. If I could only get the same functionality or figure out how to port it to Monkey that would rock.


Soap(Posted 2011) [#8]
What were you doing to get it functioning in Blitzmax?


muddy_shoes(Posted 2011) [#9]
I want to start with a desktop application that is cross platform. What would be the best free option for this?


Best? What properties would the "best" solution have for your needs? By "cross-platform" do you just mean Mac and Windows? What will your application use a database for?

The probable answer is that SQLite will do what you want and is the simplest solution. It's free as far as paying for using it but there's no solution that will be free of effort to get it to work with Monkey.

If I were you I'd be questioning whether I need a database at all before marrying the idea of needing a database module.


Soap(Posted 2011) [#10]
I want to make an address book type of application.


muddy_shoes(Posted 2011) [#11]
Okay. Is it for yourself or for distributing to other people? Are you going to want multiple users searching/adding/deleting/updating records at the same time or is this just for one person? How many contacts are we talking about? Dozens, hundreds or thousands?

If it's just a single user app intended for moderate numbers of records then simply chucking the records into an text, XML or JSON file would probably work just fine.

Don't misunderstand me. If you want to create a Monkey database module that would be great, I'm just saying that it may not be necessary.


Cartman(Posted 2011) [#12]
In my case, I'm using the SQLite database to handle all the assets, encounters, groupings, shops, in my game(RPG). I can manage the data better this way since I work in databases in my day job. Yes I could export everthing into XML and import it that way, but it's easier for me to do it in SQLite.


muddy_shoes(Posted 2011) [#13]
it's easier for me to do it in SQLite


Sure, the point isn't that databases aren't useful or that they don't make life easier when solving certain problems when a ready-made API can be pulled off the shelf. I'm just saying that it might be easier for Soap to use something else for development than to create an SQLite wrapper module.


Cartman(Posted 2011) [#14]
Agreed. I was just speaking from my needs, not what would work for Soap. Just to be clear.


Soap(Posted 2011) [#15]
I suppose that I could do without a database in this case but I will want to expand the program later on. So, sooner or later I will need a database. However, I have looked at using json but there doesn't seem to be any built in support for it either. I saw a sample class that deals with json but it lacks some functionality. If it came down to it, I will settle with json for now.


hardcoal(Posted 2011) [#16]
I have an Hirarchial database that i only need to translate to monkey
will that do?


muddy_shoes(Posted 2011) [#17]
If you write the code so that your persistence mechanism (writing to XML/JSON/Binary/SQLite/MySQL/CouchDB/Whatever) is behind an abstracted interface then you'll be ready to go if and when a database module turns up.

Things available right now: Diddy has an XML serialisation interface, there's Warpy's json implementation or there's my json lib. If there's something useful missing then the Diddy devs or myself may be open to adding it.


hardcoal(Posted 2011) [#18]
What I have is a set of Functions To Load a data base from file and to read data from it.

For Example ReadData House\Room1\XSize
or WriteData House\Room1\Color


Soap(Posted 2011) [#19]
Thanks muddy, the problem with Warpy's implementation doesn't include a way to read the input. And the way it's set up, it'll be a bit of a pain to change that.


hardcoal(Posted 2011) [#20]
my database translation takes more time then i thought
i had to over come the no goto command issue alone which
cuases all this to be a hard task.

but after getting rid of goto command i really dont miss it that much.


hardcoal(Posted 2012) [#21]
Im so angry of my self
ive almost reprogrammed my data base again just because im working on blitz3d monkey and blitzmax all together.
all got mixed in my head.

hope ill make it right this time.

im now converting my database from monkey to blitzmax

omg! i cant believe ive almost redone it!
waisting a week for nothing! again? no more.

thanks god ive done it in monkey.
im so glad monkey and blitzmax are so similar.
omg i must relax! sry


hardcoal(Posted 2012) [#22]
Soon ill release a database controller that Ive made.
whats good in it is that you can save and load data from it by address.

Example of command:

Reading: Get Spaceship/XPos

Saving: Save SpaceShip/XPos

Other Commads:

Let say you want to get the amount of spaceships you have on the database.

GetSimilarAmount SpaceShip

you can do all sorts of manipulations on the database.

Another Exmaple of use:
let say you have to Spaceships in your database and you want to read the second one. you do.

Get SpaceShip|2/Name

you can also add more then one name.

Example:

Add SpaceShip/Name/Rocky
Add spaceShip/Name/StarShip

now the spaceship have two names Rocky and Starship.

it used to work well on blitz3d and now im improving it on blitzmax
after that i will convert it to monkey.

im using it now on blitzmax and im really pleased!

Cheers