Jump to content


Photo

Gmsdb - Game Maker Simple Database V1.2


  • Please log in to reply
34 replies to this topic

#1 Catan

Catan

    GMC Member

  • GMC Member
  • 225 posts

Posted 11 June 2012 - 10:37 PM

GMSDB
GMSDB is a set of scripts for GMS and GM8.1 (for GM8.0 users, see this) I realized for my game Animus to manage the cards database. I decided to clean the scripts and generalize them so that they can be used as a generic database system written entirely in GML, without the need to use DLLs or other external resources.

The scripts are also available as a GEX extension.

Features

  • Comprehensive database system with no external dll or extensions required
  • Allows creation of an unlimited number of tables and table columns
  • Data retrieval scripts that allow complex sorting and filtering of records
  • Reads and saves database tables to the file system with its own format
  • Can read an save records to CSV files, to be edited in Excel or text editors
  • Tables and table columns are global and identified by name, no need to store and pass around table_id variables or similar.
  • Works on GM8.1 and Studio

Download V1.2.0
The zip file contains examples and scripts for GM:Studio and GM8.1.

Documentation
An online version of the manual can be found HERE

Example snippet

Spoiler


Version history
v1.2.0 - 14 March 2013
 
  • Better script descriptions Scripts include now an extensive and consistent description
  • New documentation The zip file includes now a documentation file.
  • New: db_record_find_values Performs a query in the database, but unlike the old db_record_find, this returns a ds_grid of values directly. It is also possible to specify which columns you want the script to return.
  • New: db_record_select You can pass a ds_list of record ids to this function to get a ds_grid of column values
  • New: db_record_insert_csv Populates a table with values from a CSV file
  • Obsolete: db_record_row, db_row_value, db_table_add_column, db_table_grid, db_table_grid, db_table_index These functions are not present anymore due to streamlining of the system, and introduction of better alternatives.
  • Changed: db_record_find The function is now called db_record_find_ids
  • Changed: db_table_create The function now allows the creation of an unlimited amout of columns, by passing column names in a comma separated string instead of arguments. Also, since columns have a type now, also the GM8 version requires to specify a type for each column.
  • Changed: db_record_insert The script now allows inserting values as a comma separated string. Passing values as arguments still works.
  • Changed: db_record_update The script no longer updates a single column, you can now specify a list of columns to update, and N values to insert into them.

Older versions:

Spoiler

Edited by Catan, 18 April 2013 - 07:37 AM.

  • 4

#2 peter henry

peter henry

    GMC Member

  • GMC Member
  • 71 posts

Posted 13 June 2012 - 01:07 AM

Fine. Useful!
Thanks.
  • 0

#3 Catan

Catan

    GMC Member

  • GMC Member
  • 225 posts

Posted 14 June 2012 - 12:50 PM

New version uploaded, db_record_find is much faster now with limit > 0 and no order is specified.
I also added the function db_record_find_first(table,column,value), which returns the id of the first record found in the database having value at the specified column. This function has the same results of a regular db_record_find with limit 1 and no order, but it's much faster on large data sets

Edited by Catan, 14 June 2012 - 12:51 PM.

  • 0

#4 Kuhn

Kuhn

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8

Posted 11 July 2012 - 08:32 AM

i've been looking for this thanks so much :D
  • 1

#5 Johnjwj

Johnjwj

    Question.

  • GMC Member
  • 111 posts
  • Version:GM8

Posted 11 July 2012 - 12:48 PM

Very nice system, Catan! I've been looking for something similar for a project of mine. Gave you some reputation :)
  • 0

#6 famous

famous

    GMC Member

  • GMC Member
  • 169 posts
  • Version:Unknown

Posted 11 July 2012 - 09:23 PM

Oh, i see this is similar to my Dynamic Structure List (Data-Structure) Solution. ^^ Havn't seen this before.
  • 0

#7 Catan

Catan

    GMC Member

  • GMC Member
  • 225 posts

Posted 12 July 2012 - 10:50 AM

I'm happy to see someone found this useful. Right now I'm creating some functions to import/export the db to csv files, this makes it possible to see, create and edit a database directly in excel, which can be useful also for debugging purposes.

I've also been told that this doesn't work on GM Studio. I expected it to work since as far as i know the ds_ functions have not been changed (except internally), but sadly I don't have GM Studio therefore I can't really see what's going on.

Edited by Catan, 12 July 2012 - 10:53 AM.

  • 0

#8 Hyomoto

Hyomoto

    GMC Member

  • GMC Member
  • 174 posts
  • Version:GM:Studio

Posted 15 July 2012 - 10:48 AM

I'm happy to see someone found this useful. Right now I'm creating some functions to import/export the db to csv files, this makes it possible to see, create and edit a database directly in excel, which can be useful also for debugging purposes.

I've also been told that this doesn't work on GM Studio. I expected it to work since as far as i know the ds_ functions have not been changed (except internally), but sadly I don't have GM Studio therefore I can't really see what's going on.


I'm looking for a good database system to handle some things and I'm using Gamemaker Studio. I was able to import your example and run it without errors, but there is an anomaly. It shows seven rows, but the first one is Orange, and the next six are Banana. If you delete that index, they all become Pumpkin. It doesn't appear to be a problem with the data structures though, since the data still seems to be there and may just be a glitch in the display routines.

Edited by Hyomoto, 15 July 2012 - 11:14 AM.

  • 0

#9 fastjack

fastjack

    GMC Member

  • New Member
  • 7 posts

Posted 31 July 2012 - 04:46 PM

Since one can only pass a limited number of arguments to a script in gamemaker, I presume if I wanted to make a table with say 20 columns I'd be unable to do so? How would you recommend I store such data? Would there be a relatively easy way to split the 20 or so properties of an item amongst 2 tables?
  • 0

#10 Catan

Catan

    GMC Member

  • GMC Member
  • 225 posts

Posted 01 August 2012 - 02:28 PM

Since one can only pass a limited number of arguments to a script in gamemaker, I presume if I wanted to make a table with say 20 columns I'd be unable to do so? How would you recommend I store such data? Would there be a relatively easy way to split the 20 or so properties of an item amongst 2 tables?


There's a function to add columns to a database table after it is created, meaning you can have more than 14 columns. The problem is that you will not be able to insert records in the table with a single call. Probably the only way to do this is to modify the table creation and record insertion scripts to accept a string of values divided by a separator, and parse this string.
  • 0

#11 bryneauinfo

bryneauinfo

    GMC Member

  • New Member
  • 5 posts
  • Version:GM:Studio

Posted 15 September 2012 - 08:00 PM

in studio it appears quite a few of the functions are missing.
  • 0

#12 Catan

Catan

    GMC Member

  • GMC Member
  • 225 posts

Posted 18 October 2012 - 03:42 PM

in studio it appears quite a few of the functions are missing.


I recently bought studio and I plan to make these scripts work well with it. Moreover i almost completed some functions to export and import data from csv files (useful to export and import data from excel tables).

As for the bugs on studio:
no functions are missing but some internal changes made the scripts unusable on Studio.
The main issue is the changes made to the ds_map data structure, as in GM8.1 my GMSDB assumes, for some functionalities, that the contents of the ds_map are stored sorted by key and that ds_map_find_first and ds_map_find_last return respectively the smallest key and the largest key. This is not the case anymore with GM:Studio and causes problems when sorting the results and inserting new records.
There's some work to do but it's not a big deal.

The other problem that causes this not to work is a bug with the function ds_grid_set_grid_region performed on the same ds_grid (I checked and there's already a bug report on the tracker for this), but that's a major problem since it makes impossible to delete records in a clean and fast way from the tables. I'll wait until this is fixed to release the studio version.
  • 0

#13 SamsungSchermStuk

SamsungSchermStuk

    GMC Member

  • New Member
  • 1 posts
  • Version:GM8

Posted 22 October 2012 - 12:03 PM

Thanks for the information, realy love it.
Subscribed to this tread! (H)
  • 0

#14 darkwalker247

darkwalker247

    Bullet Fox

  • GMC Member
  • 825 posts
  • Version:GM8

Posted 03 November 2012 - 01:05 AM

I love that it has powerful sorting and grouping abilities. I will definitely be using this.
  • 0

#15 Primoz128

Primoz128

    GMC Member

  • GMC Member
  • 278 posts
  • Version:GM:Studio

Posted 24 November 2012 - 01:15 PM

Look really useful, 6/10 for code formating.
  • 0

#16 Catan

Catan

    GMC Member

  • GMC Member
  • 225 posts

Posted 25 November 2012 - 07:37 PM

[...]6/10 for code formating.


I don't really get what this means, can you explain please?
  • 0

#17 Catan

Catan

    GMC Member

  • GMC Member
  • 225 posts

Posted 08 March 2013 - 01:35 PM

UPDATE: GMSDB is now GM:Studio compatible! Due to the differences between Studio and GM8, affecting heavily the sorting implementation, there are two different set of scripts, one for Studio and one for GM8. The changes are mostly internal, there are almost no changes in the function calls. The only difference is that in Studio columns are typed, meaning that you have to specify if a column holds real values or string values. For this reason you also can't share databases between GM8 and Studio.

I also added a functionality to export the tables to a CSV file, this helps debugging since this way you can check the database contents in excel or with a text editor.

Edited by Catan, 08 March 2013 - 02:05 PM.

  • 0

#18 frifrafrank

frifrafrank

    GMC Member

  • GMC Member
  • 14 posts
  • Version:Unknown

Posted 08 March 2013 - 06:09 PM

UPDATE: GMSDB is now GM:Studio compatible! Due to the differences between Studio and GM8, affecting heavily the sorting implementation, there are two different set of scripts, one for Studio and one for GM8. The changes are mostly internal, there are almost no changes in the function calls. The only difference is that in Studio columns are typed, meaning that you have to specify if a column holds real values or string values. For this reason you also can't share databases between GM8 and Studio.

I also added a functionality to export the tables to a CSV file, this helps debugging since this way you can check the database contents in excel or with a text editor.




Thank you for your work, I start to look at it and study it.
And thanks to share with the community
  • 0

#19 Catan

Catan

    GMC Member

  • GMC Member
  • 225 posts

Posted 09 March 2013 - 03:29 PM

I just updated version 1.1.1, since 1.1.0 had a problem when using limit = 1 and an offset > 0. This version also features a slight performance improvement to results sorting, and more features in the example.
  • 0

#20 Catan

Catan

    GMC Member

  • GMC Member
  • 225 posts

Posted 14 March 2013 - 05:13 PM

Sorry for the frequent updates, but I've been working on this a lot lately. I just released version 1.2 that introduces some major changes and new functionalities.

This version includes a better data retrieval system, now it is possible to return values directly into a ds_grid instead of just record ids. It is also possible to select exactly which columns to return.
Scripts are now better documented, and an external documentation is available. Moreover, there's no limit now to the number of columns a table can have, and every column has a type (real or string) associated to it in order to perform an automatic cast on insertion or update.
It is also possible to update more than one column at a time now in a single script call, by selecting which specific columns to update.
Better CSV integration allows now to import values from CSV files directly into tables.

Just a note for those wanting to upgrade: many scripts are obsolete now, and since database columns are typed, you can not use older databases into the new version. You can still import old db values to a new one using CSV files.

For details, see the change log in the open post.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users