Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / MySQL plugin for DBPro

Author
Message
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 25th Nov 2012 22:51 Edited at: 25th Nov 2012 23:16
Well, I've been recently faffin' about with MySQL on Linux and Windows and thought I might just wrap it up and give it to the DBP community for anyone who might actually have a need for it.

Some things to get you started:

1. Download MySQL from here - http://dev.mysql.com/downloads/installer/
This will also install the MySQL Workbench which you will need to test out your first database.

2. Run MySQL Workbench and create a test database. This can be quite fiddly as I found out but there is lots more information on the MySQL website on how to use it... No use asking me...

3. Make your first field an "AutoIncrement" field. You will see a line with something along the lines of:
PK NN UQ BIN UN ZF AI - Just select the last AI option to set it to "AutoIncrement".
This will then set your first field as the Primary Key.

4. Add some more fields.

5. Edit table data and only enter values in the other fields (not the Primary Key field). This will populate your first table with some test data to try this plugin out with.

6. Using the HOST, USER, PASSWD and DB names you can now make your changes to this code and run...



The extra function so far is MYSQL FETCH ROW STRING(row,index) which returns the value into a string. If you need a numeric value then use DBP's VAL() function which is more than adequate.

The plugin is attached to this post in the bottom right corner...

Have fun, and yes it's awkward. So if you do need help I'd recommend searching the MySQL website before asking here. I'm still learning MySQL so I will not have any answers for you...

There may be a need to alter and/or add extra functions to the plugin but that will come in time...

EDIT: The functions in the plugin:


EDIT2: The ".dll" file goes into the "compiler/plugins-user" directory and the ".ini" file goes into the "editor/keywords" directory of your DBPro installation location.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!

Attachments

Login to view attachments
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 25th Nov 2012 22:58 Edited at: 25th Nov 2012 23:06
Awesome, good to see this on here finally

Will give it a try shortly!

EDIT

Question: Can I use a URL for the HOST?

EDIT

Umm... where do the DLLs go? Plugins-User?

WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 25th Nov 2012 23:07
I've yet to test that out with the current database I'm faffing with on Linux for my game project which is cross-platform. The best way to find that out (as I've mentioned) is to refer to the MySQL.org website. It should be easy enough to direct the database to an online server...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 25th Nov 2012 23:12
See above

Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 27th Nov 2012 00:40
@ WLGfx,

Excellent - many thanks - this will come in v handy.

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
UncleRemus
12
Years of Service
User Offline
Joined: 19th Mar 2012
Location:
Posted: 11th Dec 2012 02:19
@MrValentine
Quote: "Umm... where do the DLLs go? Plugins-User?"


Yes, all 3rd party plugin DLLs go in this folder


As for the "URL as host" question, I haven't tried but it *should* work fine (a url is just a redirect to an IP address anyway). Easy test though just search the web for "free hosting with mysql" and set up a test server.

If you happen to test it please let me know! If not, when I begin to integrate this into my project I will post my findings (could be a month or more down the road depending on schedule though)
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 12th Dec 2012 03:21
Whilst I've been faffing about with a test sql database a few weeks ago with one on my free web hosting server I managed to get it working fine with a bit of fiddling. Although my tests were all done using c++ on linux though.

This plugin is only simply a wrapper for the latest version of the MySQL library. If any problems with the functions provided then they're most likely to be a typo in the code and I'll fix it asap.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 13th Dec 2012 02:08
@ WLGfx,

[Assuming I ever come close to finishing my RPG which will need to use a burgeoning database) if I use this plugin within DBPro and compile etc, will any notional (highly notional) later installer/player of the (improbable to complete) rpg game have to install any other drivers or dlls to play the game???

What if I just want to access the mysql database file within the game folder? what is host$ then?

p.s. thanks again for this plugin...

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 13th Dec 2012 21:40
From what I can tell you only need the mysqlclient.dll to get it running which I'm assuming can just go into the same directory as your exe. I'll trial an error a few more tests with this shortly.

After a quick nosey around the web about picking up a mysql database, it is possible to have the database local to your game. Again, I'll put together some tests for that. A database instance creates a folder for it.

So far I've only done some basic tests to get it up and running but I am due to get deeper into it as I'm starting to learn the Qt SDK package as well...

Fingers crossed I'll have something shortly...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 13th Dec 2012 23:14 Edited at: 13th Dec 2012 23:16
@ WLGfx,

Thanks v much for looking in to this.

I had a few hours (on a train) today and started looking also in to SQLite and the SQL database language.

I am ashamed to say I'm only just starting to realise how ruddy fantastic and versatile it is.

Anyways, 3 hours in and I'm abandoning DarkData for SQLite (to start with) and will also speed trial vs MySQL. With SQLite I'm going to create my own PureBasic (pureplugin) wrapper of a wrapper, so to speak... I know that there are at least two .dlls for SQLite out there in the DBPro forums - both only with the .dll and fairly basic - and I just know I can create something a whole lot more flexible and comprehensive. I'll get cracking on that, hopefully at the weekend.

But, in any event, I really want to trial MySQL - but this whole host$, 127.0.0.0.1 type stuff puts me off. Want to be right in to the database and off and runnning. Will be great if it's just a question of a line or two of DBPro code and that .dll in the project folder.... will be interested to see.

[edit]

p.s. I think I have also found a freeware piece of software which allows me to import all my MS Access database stuff (and there's lots) to SQLite. I am trialing that out as well. I like SQLite because it's the server and everything in one, with no real dependencies....

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 23rd Dec 2012 10:33
@ WLGfx,

Any luck re getting MySQL to work without server/dependencies?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 23rd Dec 2012 21:03
MySQL seems great for server hosted DB's but for local DB's there's a bit of fiddling about to get your local DB to work which is annoying. You have to stop the MySQL client and change the paths within it, then restart it. I'll look into other options for local DB's.

Originally what I was after, was to be able to create/generate and edit a database on my local hard drive and save it where I wanted to. ie. maybe using MS Access or Open Office, etc. Then for my program to just read it. MySQL client doesn't seem to allow for that without a lot of fiddling.

There's still quite a few more SQL API's out there which I will get round to testing out. This time round though I'll read up on the reviews first.

At least with SQL you can eventually transfer your database to a hosted server so I won't give up on that.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 24th Dec 2012 13:34
You can embed the mysql server inside the client application using libmysqld: http://dev.mysql.com/doc/refman/5.6/en/libmysqld.html

[b]
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 24th Dec 2012 16:20
@ Diggsey,

Many thanks - may give that a whirl. Currently trying to write a wrapper for SQLite. Add a little more functionality (aside from the SQL syntax) etc.

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 25th Dec 2012 22:32
@Diggsey - Thanks. I did actually look for the static version of that. So now to get back to finishing this and sorting out local DB's.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 25th Dec 2012 23:08
@ WLGfx,

Excellent - if you can 'wrap' this into an idiot-proof set of 'local database' commands that would be great....?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 29th Dec 2012 12:53 Edited at: 29th Dec 2012 22:14
@ WLGfx,

Got 'bored' and not entirely happy with existing support for SQLite - so made a SQLite wrapper DBPro plugin which I've named (shamefully) 'DARQLite'. See link below (and attached). Very much in a 'beta testing' stage at the mo...

http://forum.thegamecreators.com/?m=forum_view&t=202527&b=18&p=0

[edit]
Still interested to see whether you can make a work-around such that MySQL can be tamed in to a straightforward desktop database utility without servers etc and other reliances.

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...

Attachments

Login to view attachments
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 29th Dec 2012 17:24 Edited at: 29th Dec 2012 21:56
[edit] no longer relevant

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 29th Dec 2012 17:30
I've been side-tracked working on my music playback api and plugin. I'll have a good nosey into what Diggsey has posted soon and fix this... Shouldn't take me too long and I'll post the results here.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 29th Dec 2012 17:46 Edited at: 29th Dec 2012 21:57
@ WLGfx,

That would be great.

[edit] - succeeded in creating my SQLite wrapper! (see above). Still needs work. But it does work.

If you could allow commands in your plugin to shoe-horn MySQL to act like a local, serverless, no-dependencies plugin to create local databases, edit, alter them etc in SQL.... that would be great. With some demo dbpro code...

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 12th Jan 2013 17:48 Edited at: 12th Jan 2013 17:49
@ WLGfx,

Any more success with Diggsey's suggestions re making your plugin dependency free?

[edit]

P.S. I've posted a new version of the SQLITE wrapper plugin with 17 more commands - no idea if at least half of them work yet!

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 15th Jan 2013 20:06
@Duffer - I'll be checking out the functionality of SQLite soon. I'm hoping that eventually I'll pick a free api to work with for local and online databases. Recently I've been busy studying the FFT code for the music api I've been working on so not had chance to look into this again yet. Diggsey's suggestion is definitely the way to go to cut down the mass amount of dependencies required to even get started with this plugin...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!

Login to post a reply

Server time is: 2024-11-21 09:17:17
Your offset time is: 2024-11-21 09:17:17