Creating a driver

It may be that I haven't yet written a driver for a back end you want to use. I'm encouraging others to write a back end and submit it for others to use. It's not that hard to write one. Let's walk through writing one. In this case, I'm going to write a driver for mySQL.

I haven't finished this write up yet. If you need help with writing a driver in the meantime, please contact me.

Creating the library

Each driver has a separate library. My convention is to call the library cDriverName where the driver function is DriverName. So I'm creating a library called cDriverMySql for the DriverMySql object. 

DbAbstraction -vs- DataHandler

Datahandler has references to all known libraries, whereas DbAbstraction has the library passed as an argument. I recommend DbAbstraction for most usages, but I still need to support DataHandler too. DataHandler, in the end, just calls DbAbstraction anyway, so the interface simply needs to be to dbAbstraction. 

Creating the handler

It's the driver library's reponsibility to create a new instance of the driver object. 

DbAbstraction launches this

driverLibrary.createDriver(self,siloId,driverSpecific,driverOb, accessToken)

so I need to cater for that with a createDriver function, which will simply construct a Driver Object, like this...

function createDriver (handler,siloId,driverSpecific,driverOb, accessToken) {
    return new DriverMySql(handler,siloId,driverSpecific,driverOb, accessToken);

The constructor 

The returns an instance of DriverMySql.

Constants for error handling.

The can be accessed through parentHandler.getEnums(); 

For more on this, see Database abstraction with google apps script. If you would like to contribute a driver to the library, or to improve an existing one, please contact me on  G+ or our forum 

For help and more information join our forum,follow the blog or follow me on twitter .