Hello,

On 2017-03-05 01:10, John Albertini wrote:
I can't seem to grasp what I need to download / install to use SQLite?

Can someone guide me through the process?  Looking to use it with
RootsMagic.

If you want to use a tool like dBaseIII+ to examine/modify a database created by a 3rd party, then you will have to download a shell binary: http://sqlite.org/download.html => ``Precompiled Binaries for ...''.

Been using PCs since the mid 1980s and have used dBase III+ and Approach
previously.

From http://sqlite.org/about.html: ``SQLite is an in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.'' Primarily, SQLite is a library. Let's consider the following dBase program:

======
SET TALK OFF
CLEAR
CLEAR ALL
STORE 0 TO TOTAL_EMPLOYEES
STORE 0 TO TOTAL_SALARY
USE EMPLOYEE
DO WHILE .NOT. EOF()
  TOTAL_EMPLOYEES = TOTAL_EMPLOYEES + 1
  TOTAL_SALARY = TOTAL_SALARY + SALARY
  SKIP
ENDDO
@1,1 SAY "Average salary: $"
IF 0 < TOTAL_EMPLOYEES
  @1,18 SAY TOTAL_SALARY / TOTAL_EMPLOYEES PICTURE "9999.99"
ELSE
  @1,18 SAY "0.00"
ENDIF
SET TALK ON
======

If dBase had been SQLite, then you would have created the following--like ``salary.c'' file:

======
#include "dbase3.h"

int main()
{
  dbase3 *db;
  int result;

  result = dbase3_context_init(&db);

  if ( DBASE3_OK == result ) {
    dbase3_exec(db,
      "SET TALK OFF\n"
      "CLEAR\n" /* ... Rest of the program omitted */ );
    dbase3_context_done(db);
  }

  return 0;
}
======

and compiled it: ``cl salary.c dbase3.c'', and run a resulting salary.exe file.

Certainly, SQLite does not implement xBase/Vulcan language, in exchange it uses SQL (similar to SQL subsystem of DOS' FoxPro 2.5 or 2.6 AFAIR). There are no separate files per table/index, There is one self--containing file per database (which contains all tables and indices).

If you are interested in the preceding scenario, then you will have to download an amalgamation (all SQLite in one file): http://sqlite.org/download.html => ``Source Code'' => ``sqlite-amalgamation-*.zip''. It goes a working example:

1. Unzip it, and compile the shell: ``cl shell.c sqlite3.c''.

2. Run ``shell.exe'' and execute the following commands:
   .open company.db
   CREATE TABLE employees (salary);
   INSERT INTO employees VALUES (1000), (1120), (920), (840), (1220);
   .quit

Now, you have created ``company.db'' SQLite database file.

3. Create ``salary.c'' with the following content:
======
#include <stdio.h>
#include "sqlite3.h"

int moneyDisp(void *unused, int cc, char *values[], char *names[])
{
  (void)unused;
  (void)cc;
  (void)values;
  (void)names;

  if ( 0 < cc ) {
    if ( NULL != names[0] && 0 != names[0][0] ) {
      printf("%s: ", names[0]);
    }
printf("$%s\n", NULL == values[0] || 0 == values[0][0] ? "0" : values[0]);
  }

  return 0;
}

int main()
{
  int result;
  sqlite3 *db;
  char *errMsg;

  result = sqlite3_open("company.db", &db);

  if ( SQLITE_OK != result ) {
    /* open error handling */
  } else {

    result = sqlite3_exec(db,
      "SELECT AVG(salary) AS 'Average salary' FROM employees;",
      moneyDisp,
      NULL,
      &errMsg);

    if ( SQLITE_OK != result ) {
      /* select error handling */
    }

    sqlite3_free(errMsg);

    result = sqlite3_close(db);

    if ( SQLITE_OK != result ) {
      /* close error handling */
    }
  }

  return 0;
}
======

4. Compile and run:
   cl salary.c sqlite3.c
   salary.exe

You should receive something like:

Average salary: $1020.0

-- best regards

Cezary H. Noweta
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to