JavaScriptSQL (JSSQL)

JSBD_Conversor in action

In this section we see how the JSBD_Conversor database converter works through a interactive web application and lern more about its features.

 

A web interface for the conversor

The JSBD_Conversor is a class developed in PHP that lets you convert a database in MySQL or PostgreSQL to a database understandable for the JSSQL . engine

The JSBD is a set of JavaScript files containing the definition of tables, table data, indexes and other necessary parameters.

To test JSBD_Conversor I developed a PHP interface to read data from a database: JSBD converter

I divided The process into three steps:

  • Specify the connection parameters
  • Define the tables to be converted
  • Convert the database, creating the files that form the JSBD

I hope that the use of the interface to be intuitive

Warning : JSBD converter is just a test an demostration application , JSBD_Conversor can be integrated into any web application as an PHP object , although it is expected that the conversion of databases is done periodically and not on each query to the server. After creating the JSBD it can be used as often as needed without using the converter.


The default parameters allow you to access a MySQL database with the neptuno example . You can create JSBD database you want, then consult them with the JSSQL console



Using the JSBD_Conversor converter:

<?php
 //conversor class
 include_once ("cls_JSBD_Conversor.php");

 //create the conversor
 $myConversor =new JSBD_Conversor();

 //connection settings
 ///////////////////////////////////

 //server
 $myConversor->_connserv='localhost';

 //port
 $myConversor->_connport='3306';

 //user
 $myConversor->_connusr='test';

 //password
 $myConversor->_connpass='test';

 //source database
 $myConversor->_conndb='neptuno';

 //source database type (mysql / postgre)
 $myConversor->_tipo="mysql";

 //destination database settings
 ///////////////////////////////////

 //destination directory
 $myConversor->_basedir="bases";

 //name of the JSBD
 $myConversor->_nombre="categorias";


 //Tables to convert
 ///////////////////////////////////

 //table name in the JSBD
 $nombre_tabla="categorias";

 //SQL query of the data to insert in the JSBD table
 $sql="SELECT * FROM categorias";

 //types and indexes that we assign to that table
 /// fields: IdCategoria | NombreCategoria | Descripcion
 $tipos="numeric,string,string";
 $indices=" false,false,false";

 //paginated for the table (make a page each x registers)
 $paginado=0;  //(without paginated)

//add the table
 if(!$myConversor->AgregarTabla($nombre_tabla,$sql,$tipos,$indices,$paginado)) {
    print $myConversor->GetError();
    exit;
    }

 //Build the JSBD
 if(!$myConversor->Convertir()) {
    print $myConversor->GetError();
    exit;
 }

 print "Conversión Exitosa";
 php?>

We also have the option of using a configuration file to store and retrieve the configuration of the converter, for details, see the class documentation .