#1 2016-06-09 16:42:31

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 337

SQLite rror "no such module: External"

Hi @ab, I am working with revision 1.18.2716 and I having the error Error SQLITE_ERROR (1) [Step] using 3.13.0 - no such module: External, extended_errcode=1. I need create DB connections in a SQLite3 table and then I create the SQLDBConnectionProperties for external tables and create the same, I tried this two ways:

1) Create SQLite3 tables first and then external tables

  fModel = TSQLModel.Create([TSQLDBConnection, Table2], 'root');
  fServerRest := TSQLRestServerDB.Create(fModel, 'data.db', False);
  fServerRest.CreateMissingTables;
  
  // fill TSQLDBConnection with DB connection data ..
  fDBConnections = CreateAllConnectionProperties; // from TSQLDBConnection

  fSQLConnProp := fDBConnections.GetConnectionProp('ConnectionName');

  // create the external table
  fModel.AddTable(TSQLExternalTable);

  // map table and fields
  VirtualTableExternalMap(fModel, TSQLExternalTable, fSQLConnProp, 'EXTERNAL_TABLE').MapFields(['ID', 'ID']).MapAutoKeywordFields;

  // create missing tables again
  fServerRest.CreateMissingTables; // --> HERE THE EXCEPTION IS RAISED

1) Create all tables and then drop the external tables for recreating

  fModel = TSQLModel.Create([TSQLDBConnection, Table2, TSQLExternalTable], 'root');
  fServerRest := TSQLRestServerDB.Create(fModel, 'data.db', False);
  fServerRest.CreateMissingTables;
  
  // fill TSQLDBConnection with DB connection data ..
  fDBConnections = CreateAllConnectionProperties; // from TSQLDBConnection

  fSQLConnProp := fDBConnections.GetConnectionProp('ConnectionName');

  // drop the external table from the SQLite3 database
  fServerRest.EngineExecute('drop table ExternalTable');
  // map table and fields
  VirtualTableExternalMap(fModel, TSQLExternalTable, fSQLConnProp, 'EXTERNAL_TABLE').MapFields(['ID', 'ID']).MapAutoKeywordFields;

  // create missing tables again
  fServerRest.CreateMissingTables; // --> HERE THE EXCEPTION IS RAISED

What I am doing wrong ? How I create tables in two phases in SQLite3 ?

Thanks in advance.


Esteban

Offline

#2 2016-06-09 18:18:39

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,603
Website

Re: SQLite rror "no such module: External"

CreateMissingTables should be called ONCE, and AFTER the external tables are setup.
You have a first fServerRest.CreateMissingTable which does not make sense.

Offline

#3 2016-06-09 18:28:30

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 337

Re: SQLite rror "no such module: External"

Yes, I know that I am calling twice CreateMissingTables, I need create an initial table where I store the migrated DB connections and then create the connection properties for external tables.

I'll think another solution.

UPDATE: @ab, but if I drop the real SQLite3 table, that should not allow create the table again ?

Thanks.

Last edited by EMartin (2016-06-09 18:33:01)


Esteban

Offline

#4 2016-06-10 12:50:24

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 337

Re: SQLite rror "no such module: External"

@ab, if I drop the real SQLite3 table, that should not allow create the table again ?

Thanks.


Esteban

Offline

Board footer

Powered by FluxBB