The MBS SQL Plugin
An alternative way to connect to databases
Issue: 14.1 (January/February 2016)
Author: Christian Schmitz
Author Bio: Christian Schmitz is the creator of the Monkeybread Software Xojo Plugins.
Article Description: No description available.
Article Length (in bytes): 24,034
Starting Page Number: 24
Article Number: 14105
Related Web Link(s):
Excerpt of article text...
While Xojo ships with a couple of database plugins for various database vendors, some developers have special needs. For example with SQLite there could be a newer version of the SQLite library or one with special extensions compiled in like encryption. Some developers related to geography use spatialite, a special version of SQLite with additional commands and functions to work with geo coordinates. Others may simply want to have more low level options or simply a support for a database which is not directly available in Xojo like DB2.
The MBS SQL Plugin is an alternative interface to databases in Xojo. It has two sides: First, the
SQLDatabaseMBSclass, which is a subclass of Xojo's database class. This makes it a perfect drop-in replacement for the built in Xojo database plugins. You can simply use the
DatabaseRecordclasses. But as you use Xojo's database class, you must have the database license.
The second side is the native plugin interface with classes like
SQLCommandMBS. They provide much more functionality and more options for the various databases. And those classes work without a Xojo database license unless you use RecordSet class.
While you can decide for using
SQLConnectionMBSclass as your interface, you can still use RecordSets by requesting a
SQLCommandMBSas a recordset. We do have the methods for this. The recordset internally has a
SQLCommandMBSobject anyway. Similar for
SQLDatabaseMBSclass you can request the underlying
SQLConnectionMBSobject if needed. Part of your code can use one interface and another code can use a
RecordSet, for example to use with reporting classes.
Lets just start connecting to a database with MySQL and run a query. As you will see, the usage is very similar to one of the built-in Xojo database classes. First you need a new instance of the database class, so you write a line like this:
...End of Excerpt. Please purchase the magazine to read the full article.