Index: tol_tests/tol/database/sqlite/test_002/test_sqlite.tol
===================================================================
--- tol_tests/tol/database/sqlite/test_002/test_sqlite.tol	(revision a5f3e8fcc039a00781787b069f32f9da32d4f026)
+++ tol_tests/tol/database/sqlite/test_002/test_sqlite.tol	(revision a5f3e8fcc039a00781787b069f32f9da32d4f026)
@@ -0,0 +1,58 @@
+NameBlock connection = DBConnect::Create (
+  "db_test", "_", "_", 
+  "sqlite", "../db_test.db", "", 
+  "Checking SQLite connection from TOL"
+);
+
+Real connection::Open(?);
+
+Real DBExecQuery("
+DROP TABLE IF EXISTS studQuRg;
+CREATE TABLE IF NOT EXISTS studQuRg(
+  co_code VARCHAR(16),
+  vl_qualify FLOAT,
+  dt_register DATE
+)");
+
+
+Real numReg = 10000;
+Real t0 = Copy(Time);
+
+Text query.insertValues = "
+PRAGMA synchronous = 0; 
+BEGIN;\n"<<
+SetSum(For(1,numReg,Text(Real k)
+{
+  "INSERT INTO studQuRg VALUES"
+  "('S"<<IntRand(111111,999999)<<"', "<<
+  Real Rand(0,10)<<", "<<
+  FormatDate(Today-IntRand(10,100),"'%c%Y-%m-%d'")<<");"
+}))+";
+COMMIT;
+PRAGMA synchronous = 2; 
+";
+Real tm.insertBuild = (Copy(Time)-t0)/numReg;
+
+Real t0 := Copy(Time);
+Real DBExecQuery(query.insertValues);
+Real tm.insertRun = (Copy(Time)-t0)/numReg;
+
+Set DBTable("SELECT * FROM studQuRg");
+
+Real connection::Close(?);
+
+/*
+Text query.insert = "
+PRAGMA fullfsync = 0;
+INSERT INTO studQuRg "<<
+SetSum(For(1,2000,Text(Real k)
+{
+  "\n"<<
+  If(k>1,"UNION ALL\n","")<<
+  "SELECT 'S"<<IntRand(111111,999999)<<"' as co_code, "<<
+  Real Rand(0,10)<<" as vl_qualify, "<<
+  FormatDate(Today-IntRand(10,100),"'%c%Y-%m-%d'")<<" as qualify"
+}))+";
+PRAGMA fullfsync = 1;";
+*/
+
Index: tol_tests/tol/database/sqlite/test_003/config.tol
===================================================================
--- tol_tests/tol/database/sqlite/test_003/config.tol	(revision a5f3e8fcc039a00781787b069f32f9da32d4f026)
+++ tol_tests/tol/database/sqlite/test_003/config.tol	(revision a5f3e8fcc039a00781787b069f32f9da32d4f026)
@@ -0,0 +1,17 @@
+NameBlock connection = DBConnect::Create (
+  "db_test", "_", "_", 
+  "sqlite", "../db_test.db", "", 
+  "Checking SQLite connection from TOL"
+);
+
+@TimeSet tms = @TimeSet(Daily);
+Date first = y2010;
+Date last  = y2015m12d31;
+Real tableNumber = 100;
+Real seriesByTable = 100;
+
+Real seriesNumber = seriesByTable*tableNumber;
+Real seriesLength = DateDif($tms,first,last);
+Real dataLength = seriesLength*seriesNumber;
+Real GlobalizeSeries := False;
+
Index: tol_tests/tol/database/sqlite/test_003/load.tol
===================================================================
--- tol_tests/tol/database/sqlite/test_003/load.tol	(revision a5f3e8fcc039a00781787b069f32f9da32d4f026)
+++ tol_tests/tol/database/sqlite/test_003/load.tol	(revision a5f3e8fcc039a00781787b069f32f9da32d4f026)
@@ -0,0 +1,28 @@
+#Embed "config.tol";
+
+Real connection::Open(?);
+
+Set sqlite_master = DBTable("select * from sqlite_master ");
+
+Real loadTime = Copy(Time);
+Set series = For(1,tableNumber,Set(Real tab) {
+  Text tabId = "TRS"<<FormatReal(tab,"%05.0lf");
+  WriteLn("Loading random series for table "+tabId);
+//Set ser = { DBTable(
+//  "SELECT * FROM "+tabId+";") };
+  Set ser = { DBSeries(
+    "SELECT * FROM "+tabId+";",
+    $tms,
+    For(1,seriesByTable,Text(Real k)
+    {
+      tabId+".RS_"<<FormatReal(k,"%05.0lf")
+    })) }; 
+  Eval(tabId+"=ser")
+});
+
+Real loadTime := Copy(Time)-loadTime;
+
+Real loadTimeByDatum = loadTime / dataLength;
+
+Real connection::Close(?);
+
Index: tol_tests/tol/database/sqlite/test_003/save.tol
===================================================================
--- tol_tests/tol/database/sqlite/test_003/save.tol	(revision a5f3e8fcc039a00781787b069f32f9da32d4f026)
+++ tol_tests/tol/database/sqlite/test_003/save.tol	(revision a5f3e8fcc039a00781787b069f32f9da32d4f026)
@@ -0,0 +1,39 @@
+#Embed "config.tol";
+
+Real connection::Open(?);
+
+Real genTime = 0;
+Real insertTime = 0;
+
+//Real tab = 1;
+Set For(1,tableNumber,Real(Real tab) {
+  Text tabId = "TRS"<<FormatReal(tab,"%05.0lf");
+  WriteLn("Generating random series for table "+tabId);
+  Real t0Gen = Copy(Time);
+  Set series = For(1,seriesByTable,Serie(Real k)
+  {
+    Serie ser = SubSer(Gaussian(0,1,$tms),first,last);
+    Eval("RS_"<<FormatReal(k,"%05.0lf")+"=ser")
+  });
+  Real genTime := genTime + Copy(Time) - t0Gen;
+  WriteLn("Inserting random series in table "+tabId);
+  Real t0Insert = Copy(Time);
+  Real DBExecQuery("
+  PRAGMA synchronous = 0;
+  BEGIN;
+  CREATE TABLE IF NOT EXISTS "+tabId+"(unused float);
+  ");
+  Real DBCreateSeriesTable(tabId,series,"dt_date", "datetime"); 
+  Real DBExecQuery("
+  COMMIT;
+  PRAGMA synchronous = 2;
+  ");
+  Real insertTime := insertTime + Copy(Time) - t0Insert;
+  True
+});
+  
+Real genTimeByDatum = genTime / dataLength;
+Real insertTimeByDatum = insertTime / dataLength;
+
+Real connection::Close(?);
+
Index: tol_tests/tol/database/sqlite/test_004/test_sqlite.tol
===================================================================
--- tol_tests/tol/database/sqlite/test_004/test_sqlite.tol	(revision a5f3e8fcc039a00781787b069f32f9da32d4f026)
+++ tol_tests/tol/database/sqlite/test_004/test_sqlite.tol	(revision a5f3e8fcc039a00781787b069f32f9da32d4f026)
@@ -0,0 +1,41 @@
+NameBlock connection = DBConnect::Create (
+  "db_test", "_", "_", 
+  "sqlite", "../db_test.db", "", 
+  "Checking SQLite connection from TOL"
+);
+
+Real connection::Open(?);
+Real DBExecQuery("PRAGMA foreign_keys = ON;");
+Real mustBeOk = DBExecQuery("
+BEGIN;
+DROP TABLE IF EXISTS track;
+DROP TABLE IF EXISTS artist;
+CREATE TABLE IF NOT EXISTS artist(
+  artistid    INTEGER PRIMARY KEY, 
+  artistname  TEXT
+);
+CREATE TABLE IF NOT EXISTS track(
+  trackid     INTEGER, 
+  trackname   TEXT, 
+  trackartist INTEGER,
+  FOREIGN KEY(trackartist) REFERENCES artist(artistid)
+);
+INSERT INTO artist VALUES(1, 'Dean Martin');
+INSERT INTO artist VALUES(2, 'Frank Sinatra');
+INSERT INTO artist VALUES(3, 'Sammy Davis Jr.');
+INSERT INTO track VALUES(11, 'ThatŽs Amore', 1);
+INSERT INTO track VALUES(12, 'Christmas Blues', 1);
+INSERT INTO track VALUES(13, 'My Way', 2);
+INSERT INTO track VALUES(15, 'Boogie Woogie', 3);
+COMMIT;
+");
+
+Real mustFail = DBExecQuery("
+INSERT INTO track VALUES(0, 'Macarena', 0);
+");
+
+Set artist = DBTable("SELECT * FROM artist");
+Set track = DBTable("SELECT * FROM track");
+
+Real connection::Close(?);
+
