Arne Vajhøj
2020-06-17 18:23:36 UTC
SQLite has been mentioned a lot recently.
Here is a little demo.
C:\Work\sqlite>del test.db
C:\Work\sqlite>type cre.sql
CREATE TABLE multi (
id INTEGER PRIMARY KEY,
msg VARCHAR(50)
);
C:\Work\sqlite>sqlite3 test.db 0<cre.sql
C:\Work\sqlite>type test.sql
INSERT INTO multi(msg) VALUES('Hi from CLI tool on Windows');
SELECT id,msg FROM multi;
C:\Work\sqlite>sqlite3 test.db 0<test.sql
1|Hi from CLI tool on Windows
C:\Work\sqlite>type test.py
import sqlite3
con = sqlite3.connect('test.db')
c = con.cursor()
c.execute('INSERT INTO multi(msg) VALUES(?)', ('Hi from Python on
Windows',))
c.execute('SELECT id,msg FROM multi')
for row in c.fetchall():
print('%d %s' % (row[0], row[1]))
con.commit()
con.close()
C:\Work\sqlite>python test.py
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
C:\Work\sqlite>type test.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sqlite3.h"
static char *DB = "test.db";
static char *INS = "INSERT INTO multi(msg) VALUES(?)";
static char *SEL = "SELECT id,msg FROM multi";
static char *TXT = "Hi from C on Windows";
int main()
{
sqlite3 *con;
sqlite3_stmt *ins, *sel;
int stat;
stat = sqlite3_open(DB, &con);
if(stat)
{
printf("Error in open: %s\n", sqlite3_errmsg(con));
exit(1);
}
stat = sqlite3_prepare(con, INS, strlen(INS), &ins, NULL);
if(stat)
{
printf("Error in prepare: %s\n", sqlite3_errmsg(con));
exit(1);
}
stat = sqlite3_bind_text(ins, 1, TXT, strlen(TXT), NULL);
if(stat)
{
printf("Error in bind: %s\n", sqlite3_errmsg(con));
exit(1);
}
stat = sqlite3_step(ins);
if(stat != SQLITE_DONE)
{
printf("Error in step: %s\n", sqlite3_errmsg(con));
exit(1);
}
sqlite3_finalize(ins);
stat = sqlite3_prepare(con, SEL, strlen(SEL), &sel, NULL);
if(stat)
{
printf("Error in prepare: %s\n", sqlite3_errmsg(con));
exit(1);
}
while(sqlite3_step(sel) == SQLITE_ROW)
{
printf("%d %s\n", sqlite3_column_int(sel, 0),
sqlite3_column_text(sel, 1));
}
sqlite3_finalize(sel);
sqlite3_close(con);
return 0;
}
C:\Work\sqlite>gcc -IC:\DivNative\32bit\sqlite3 test.c
C:\DivNative\32bit\sqlite
3\sqlite3.c -o test.exe
C:\Work\sqlite>test
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
3 Hi from C on Windows
C:\Work\sqlite>type test.pas
program test;
uses
SQLDB, SQLite3Conn;
var
con : TSQLite3Connection;
tx : TSQLTransaction;
ins, sel : TSQLQuery;
begin
con := TSQLite3Connection.Create(nil);
tx := TSQLTransaction.Create(con);
con.DatabaseName := 'test.db';
con.Transaction := tx;
con.Open;
tx.StartTransaction;
ins := TSQLQuery.Create(nil);
ins.DataBase := con;
ins.SQL.Text := 'INSERT INTO multi(msg) VALUES(:msg)';
ins.Params.ParamByName('msg').AsString := 'Hi from Pascal on Windows';
ins.ExecSQL;
if ins.RowsAffected <> 1 then begin
writeln('INSERT error');
halt;
end;
ins.Close;
ins.Free;
tx.Commit;
sel:= TSQLQuery.Create(nil);
sel.DataBase := con;
sel.SQL.Text := 'SELECT id,msg FROM multi';
sel.Open;
while not sel.EOF do begin
writeln(sel.FieldByName('id').AsInteger:1,'
',sel.FieldByName('msg').AsString);
sel.Next;
end;
sel.Close;
sel.Free;
tx.Free;
con.Close;
con.Free;
end.
C:\Work\sqlite>fpc test.pas
Free Pascal Compiler version 3.0.4 [2019/10/27] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Win64 for x64
Compiling test.pas
Linking test.exe
43 lines compiled, 0.7 sec, 503552 bytes code, 16228 bytes data
C:\Work\sqlite>test
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
3 Hi from C on Windows
4 Hi from Pascal on Windows
C:\Work\sqlite>type test.java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Test {
private static final String CONURL = "jdbc:sqlite:test.db";
public static void main(String[] args) throws Exception {
Class.forName("org.sqlite.JDBC");
Connection con = DriverManager.getConnection(CONURL);
PreparedStatement ins = con.prepareStatement("INSERT INTO
multi(msg) VALUES(?)");
ins.setString(1, "Hi from Java on Windows");
ins.executeUpdate();
PreparedStatement sel = con.prepareStatement("SELECT id,msg
FROM multi");
ResultSet rs = sel.executeQuery();
while(rs.next()) {
System.out.printf("%d %s\n", rs.getInt(1), rs.getString(2));
}
con.close();
}
}
C:\Work\sqlite>javac Test.java
C:\Work\sqlite>java -cp .;C:\DivJava\sqlite-jdbc-3.31.1\target\* Test
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
3 Hi from C on Windows
4 Hi from Pascal on Windows
5 Hi from Java on Windows
C:\Work\sqlite>type test.cs
using System;
using System.Data;
using System.Data.SQLite;
public class Test
{
public static void Main(string[] args)
{
using(SQLiteConnection con = new SQLiteConnection("Data
Source=test.db"))
{
con.Open();
using(SQLiteCommand ins = new SQLiteCommand("INSERT INTO
multi(msg) VALUES(@msg)", con))
{
ins.Parameters.Add("@msg", DbType.String, 50);
ins.Parameters["@msg"].Value = "Hi from C# on Windows";
ins.ExecuteNonQuery();
}
using(SQLiteCommand sel = new SQLiteCommand("SELECT id,msg
FROM multi", con))
{
using(SQLiteDataReader rdr = sel.ExecuteReader())
{
while(rdr.Read())
{
Console.WriteLine("{0} {1}", rdr["id"],
rdr["msg"]);
}
}
}
}
}
}
C:\Work\sqlite>csc /r:System.Data.SQLite.dll test.cs
Microsoft (R) Visual C# Compiler version 3.5.0-beta4-20153-05 (20b9af91)
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Work\sqlite>test
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
3 Hi from C on Windows
4 Hi from Pascal on Windows
5 Hi from Java on Windows
6 Hi from C# on Windows
C:\Work\sqlite>sqlite3 test.db 0<test.sql
1|Hi from CLI tool on Windows
2|Hi from Python on Windows
3|Hi from C on Windows
4|Hi from Pascal on Windows
5|Hi from Java on Windows
6|Hi from C# on Windows
7|Hi from CLI tool on Windows
C:\Work\sqlite>ftp -s:upload.dat 192.168.0.10
Connected to 192.168.0.10.
220 arne1 HGFTP server V3.2-4 ready.
User (192.168.0.10:(none)):
331 Username "arne" Okay, need password.
230-User "ARNE" logged in, 17-JUN-2020 14:09:23 -0400, proceed.
230 Connection closes if idle for 5 min.
ftp> cd sqlite
250 Current directory /disk2/arne/sqlite, completed.
ftp> bin
200 TYPE I Okay.
ftp> put test.db
200 Port 192,168,0,140,235,32 Okay.
150 Binary Store of TEST.DB;3 Started; Opening data connection. (0 bytes)
226 File transfer Okay; Closing data connection.
ftp: 8192 bytes sent in 0.00Seconds 8192000.00Kbytes/sec.
ftp> quit
221 Service closing control connection.
$ type test.sql
INSERT INTO multi(msg) VALUES('Hi from CLI tool on VMS');
SELECT id,msg FROM multi;
$ sqlite3 test.db -init test.sql
1|Hi from CLI tool on Windows
2|Hi from Python on Windows
3|Hi from C on Windows
4|Hi from Pascal on Windows
5|Hi from Java on Windows
6|Hi from C# on Windows
7|Hi from CLI tool on Windows
8|Hi from CLI tool on VMS
$ type test.py
import sqlite3
con = sqlite3.connect('test.db')
c = con.cursor()
c.execute('INSERT INTO multi(msg) VALUES(?)', ('Hi from Python on VMS',))
c.execute('SELECT id,msg FROM multi')
for row in c.fetchall():
print('%d %s' % (row[0], row[1]))
con.commit()
con.close()
$ python test.py
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
3 Hi from C on Windows
4 Hi from Pascal on Windows
5 Hi from Java on Windows
6 Hi from C# on Windows
7 Hi from CLI tool on Windows
8 Hi from CLI tool on VMS
9 Hi from Python on VMS
$ type test.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sqlite3.h"
static char *DB = "test.db";
static char *INS = "INSERT INTO multi(msg) VALUES(?)";
static char *SEL = "SELECT id,msg FROM multi";
static char *TXT = "Hi from C on VMS";
int main()
{
sqlite3 *con;
sqlite3_stmt *ins, *sel;
int stat;
stat = sqlite3_open(DB, &con);
if(stat)
{
printf("Error in open: %s\n", sqlite3_errmsg(con));
exit(1);
}
stat = sqlite3_prepare(con, INS, strlen(INS), &ins, NULL);
if(stat)
{
printf("Error in prepare: %s\n", sqlite3_errmsg(con));
exit(1);
}
stat = sqlite3_bind_text(ins, 1, TXT, strlen(TXT), NULL);
if(stat)
{
printf("Error in bind: %s\n", sqlite3_errmsg(con));
exit(1);
}
stat = sqlite3_step(ins);
if(stat != SQLITE_DONE)
{
printf("Error in step: %s\n", sqlite3_errmsg(con));
exit(1);
}
sqlite3_finalize(ins);
stat = sqlite3_prepare(con, SEL, strlen(SEL), &sel, NULL);
if(stat)
{
printf("Error in prepare: %s\n", sqlite3_errmsg(con));
exit(1);
}
while(sqlite3_step(sel) == SQLITE_ROW)
{
printf("%d %s\n", sqlite3_column_int(sel, 0),
sqlite3_column_text(sel, 1));
}
sqlite3_finalize(sel);
sqlite3_close(con);
return 0;
}
$ cc/include=sqlite3_include: test.c
$ link test+sys$input/opt
sqlite3shr/share
$
$ run test
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
3 Hi from C on Windows
4 Hi from Pascal on Windows
5 Hi from Java on Windows
6 Hi from C# on Windows
7 Hi from CLI tool on Windows
8 Hi from CLI tool on VMS
9 Hi from Python on VMS
10 Hi from C on VMS
$ type test.pas
[inherit('sqlite', 'psqlite')]
program test(input, output);
var
con : sqlite_ptr;
ins, sel : sqlite_stmt_ptr;
begin
con := psqlite_open('test.db');
if con = 0 then begin
writeln('Error in open: ', psqlite_errmsg(con));
halt;
end;
ins := psqlite_prepare(con, 'INSERT INTO multi(msg) VALUES(?)');
if ins = 0 then begin
writeln('Error in prepare: ', psqlite_errmsg(con));
halt;
end;
if not psqlite_bind_text(ins, 1, 'Hi from Pascal on VMS') then begin
writeln('Error in bind: ', psqlite_errmsg(con));
halt;
end;
if not psqlite_step_nonquery(ins) then begin
writeln('Error in step: ', psqlite_errmsg(con));
halt;
end;
sel := psqlite_prepare(con, 'SELECT id,msg FROM multi');
if sel = 0 then begin
writeln('Error in prepare: ', psqlite_errmsg(con));
halt;
end;
while psqlite_step_query(sel) do begin
writeln(psqlite_column_int(sel, 0):1, ' ',
psqlite_column_text(sel, 1));
end;
psqlite_finalize(sel);
psqlite_close(con);
end.
$ pas test
$ link test + psqlite/opt + sqlite/opt
psqlite
sqlite
sqlite3shr/share
$ run test
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
3 Hi from C on Windows
4 Hi from Pascal on Windows
5 Hi from Java on Windows
6 Hi from C# on Windows
7 Hi from CLI tool on Windows
8 Hi from CLI tool on VMS
9 Hi from Python on VMS
10 Hi from C on VMS
11 Hi from Pascal on VMS
$ sqlite3 test.db -init test.sql
1|Hi from CLI tool on Windows
2|Hi from Python on Windows
3|Hi from C on Windows
4|Hi from Pascal on Windows
5|Hi from Java on Windows
6|Hi from C# on Windows
7|Hi from CLI tool on Windows
8|Hi from CLI tool on VMS
9|Hi from Python on VMS
10|Hi from C on VMS
11|Hi from Pascal on VMS
12|Hi from CLI tool on VMS
Arne
Here is a little demo.
C:\Work\sqlite>del test.db
C:\Work\sqlite>type cre.sql
CREATE TABLE multi (
id INTEGER PRIMARY KEY,
msg VARCHAR(50)
);
C:\Work\sqlite>sqlite3 test.db 0<cre.sql
C:\Work\sqlite>type test.sql
INSERT INTO multi(msg) VALUES('Hi from CLI tool on Windows');
SELECT id,msg FROM multi;
C:\Work\sqlite>sqlite3 test.db 0<test.sql
1|Hi from CLI tool on Windows
C:\Work\sqlite>type test.py
import sqlite3
con = sqlite3.connect('test.db')
c = con.cursor()
c.execute('INSERT INTO multi(msg) VALUES(?)', ('Hi from Python on
Windows',))
c.execute('SELECT id,msg FROM multi')
for row in c.fetchall():
print('%d %s' % (row[0], row[1]))
con.commit()
con.close()
C:\Work\sqlite>python test.py
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
C:\Work\sqlite>type test.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sqlite3.h"
static char *DB = "test.db";
static char *INS = "INSERT INTO multi(msg) VALUES(?)";
static char *SEL = "SELECT id,msg FROM multi";
static char *TXT = "Hi from C on Windows";
int main()
{
sqlite3 *con;
sqlite3_stmt *ins, *sel;
int stat;
stat = sqlite3_open(DB, &con);
if(stat)
{
printf("Error in open: %s\n", sqlite3_errmsg(con));
exit(1);
}
stat = sqlite3_prepare(con, INS, strlen(INS), &ins, NULL);
if(stat)
{
printf("Error in prepare: %s\n", sqlite3_errmsg(con));
exit(1);
}
stat = sqlite3_bind_text(ins, 1, TXT, strlen(TXT), NULL);
if(stat)
{
printf("Error in bind: %s\n", sqlite3_errmsg(con));
exit(1);
}
stat = sqlite3_step(ins);
if(stat != SQLITE_DONE)
{
printf("Error in step: %s\n", sqlite3_errmsg(con));
exit(1);
}
sqlite3_finalize(ins);
stat = sqlite3_prepare(con, SEL, strlen(SEL), &sel, NULL);
if(stat)
{
printf("Error in prepare: %s\n", sqlite3_errmsg(con));
exit(1);
}
while(sqlite3_step(sel) == SQLITE_ROW)
{
printf("%d %s\n", sqlite3_column_int(sel, 0),
sqlite3_column_text(sel, 1));
}
sqlite3_finalize(sel);
sqlite3_close(con);
return 0;
}
C:\Work\sqlite>gcc -IC:\DivNative\32bit\sqlite3 test.c
C:\DivNative\32bit\sqlite
3\sqlite3.c -o test.exe
C:\Work\sqlite>test
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
3 Hi from C on Windows
C:\Work\sqlite>type test.pas
program test;
uses
SQLDB, SQLite3Conn;
var
con : TSQLite3Connection;
tx : TSQLTransaction;
ins, sel : TSQLQuery;
begin
con := TSQLite3Connection.Create(nil);
tx := TSQLTransaction.Create(con);
con.DatabaseName := 'test.db';
con.Transaction := tx;
con.Open;
tx.StartTransaction;
ins := TSQLQuery.Create(nil);
ins.DataBase := con;
ins.SQL.Text := 'INSERT INTO multi(msg) VALUES(:msg)';
ins.Params.ParamByName('msg').AsString := 'Hi from Pascal on Windows';
ins.ExecSQL;
if ins.RowsAffected <> 1 then begin
writeln('INSERT error');
halt;
end;
ins.Close;
ins.Free;
tx.Commit;
sel:= TSQLQuery.Create(nil);
sel.DataBase := con;
sel.SQL.Text := 'SELECT id,msg FROM multi';
sel.Open;
while not sel.EOF do begin
writeln(sel.FieldByName('id').AsInteger:1,'
',sel.FieldByName('msg').AsString);
sel.Next;
end;
sel.Close;
sel.Free;
tx.Free;
con.Close;
con.Free;
end.
C:\Work\sqlite>fpc test.pas
Free Pascal Compiler version 3.0.4 [2019/10/27] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Win64 for x64
Compiling test.pas
Linking test.exe
43 lines compiled, 0.7 sec, 503552 bytes code, 16228 bytes data
C:\Work\sqlite>test
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
3 Hi from C on Windows
4 Hi from Pascal on Windows
C:\Work\sqlite>type test.java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Test {
private static final String CONURL = "jdbc:sqlite:test.db";
public static void main(String[] args) throws Exception {
Class.forName("org.sqlite.JDBC");
Connection con = DriverManager.getConnection(CONURL);
PreparedStatement ins = con.prepareStatement("INSERT INTO
multi(msg) VALUES(?)");
ins.setString(1, "Hi from Java on Windows");
ins.executeUpdate();
PreparedStatement sel = con.prepareStatement("SELECT id,msg
FROM multi");
ResultSet rs = sel.executeQuery();
while(rs.next()) {
System.out.printf("%d %s\n", rs.getInt(1), rs.getString(2));
}
con.close();
}
}
C:\Work\sqlite>javac Test.java
C:\Work\sqlite>java -cp .;C:\DivJava\sqlite-jdbc-3.31.1\target\* Test
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
3 Hi from C on Windows
4 Hi from Pascal on Windows
5 Hi from Java on Windows
C:\Work\sqlite>type test.cs
using System;
using System.Data;
using System.Data.SQLite;
public class Test
{
public static void Main(string[] args)
{
using(SQLiteConnection con = new SQLiteConnection("Data
Source=test.db"))
{
con.Open();
using(SQLiteCommand ins = new SQLiteCommand("INSERT INTO
multi(msg) VALUES(@msg)", con))
{
ins.Parameters.Add("@msg", DbType.String, 50);
ins.Parameters["@msg"].Value = "Hi from C# on Windows";
ins.ExecuteNonQuery();
}
using(SQLiteCommand sel = new SQLiteCommand("SELECT id,msg
FROM multi", con))
{
using(SQLiteDataReader rdr = sel.ExecuteReader())
{
while(rdr.Read())
{
Console.WriteLine("{0} {1}", rdr["id"],
rdr["msg"]);
}
}
}
}
}
}
C:\Work\sqlite>csc /r:System.Data.SQLite.dll test.cs
Microsoft (R) Visual C# Compiler version 3.5.0-beta4-20153-05 (20b9af91)
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Work\sqlite>test
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
3 Hi from C on Windows
4 Hi from Pascal on Windows
5 Hi from Java on Windows
6 Hi from C# on Windows
C:\Work\sqlite>sqlite3 test.db 0<test.sql
1|Hi from CLI tool on Windows
2|Hi from Python on Windows
3|Hi from C on Windows
4|Hi from Pascal on Windows
5|Hi from Java on Windows
6|Hi from C# on Windows
7|Hi from CLI tool on Windows
C:\Work\sqlite>ftp -s:upload.dat 192.168.0.10
Connected to 192.168.0.10.
220 arne1 HGFTP server V3.2-4 ready.
User (192.168.0.10:(none)):
331 Username "arne" Okay, need password.
230-User "ARNE" logged in, 17-JUN-2020 14:09:23 -0400, proceed.
230 Connection closes if idle for 5 min.
ftp> cd sqlite
250 Current directory /disk2/arne/sqlite, completed.
ftp> bin
200 TYPE I Okay.
ftp> put test.db
200 Port 192,168,0,140,235,32 Okay.
150 Binary Store of TEST.DB;3 Started; Opening data connection. (0 bytes)
226 File transfer Okay; Closing data connection.
ftp: 8192 bytes sent in 0.00Seconds 8192000.00Kbytes/sec.
ftp> quit
221 Service closing control connection.
$ type test.sql
INSERT INTO multi(msg) VALUES('Hi from CLI tool on VMS');
SELECT id,msg FROM multi;
$ sqlite3 test.db -init test.sql
1|Hi from CLI tool on Windows
2|Hi from Python on Windows
3|Hi from C on Windows
4|Hi from Pascal on Windows
5|Hi from Java on Windows
6|Hi from C# on Windows
7|Hi from CLI tool on Windows
8|Hi from CLI tool on VMS
$ type test.py
import sqlite3
con = sqlite3.connect('test.db')
c = con.cursor()
c.execute('INSERT INTO multi(msg) VALUES(?)', ('Hi from Python on VMS',))
c.execute('SELECT id,msg FROM multi')
for row in c.fetchall():
print('%d %s' % (row[0], row[1]))
con.commit()
con.close()
$ python test.py
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
3 Hi from C on Windows
4 Hi from Pascal on Windows
5 Hi from Java on Windows
6 Hi from C# on Windows
7 Hi from CLI tool on Windows
8 Hi from CLI tool on VMS
9 Hi from Python on VMS
$ type test.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sqlite3.h"
static char *DB = "test.db";
static char *INS = "INSERT INTO multi(msg) VALUES(?)";
static char *SEL = "SELECT id,msg FROM multi";
static char *TXT = "Hi from C on VMS";
int main()
{
sqlite3 *con;
sqlite3_stmt *ins, *sel;
int stat;
stat = sqlite3_open(DB, &con);
if(stat)
{
printf("Error in open: %s\n", sqlite3_errmsg(con));
exit(1);
}
stat = sqlite3_prepare(con, INS, strlen(INS), &ins, NULL);
if(stat)
{
printf("Error in prepare: %s\n", sqlite3_errmsg(con));
exit(1);
}
stat = sqlite3_bind_text(ins, 1, TXT, strlen(TXT), NULL);
if(stat)
{
printf("Error in bind: %s\n", sqlite3_errmsg(con));
exit(1);
}
stat = sqlite3_step(ins);
if(stat != SQLITE_DONE)
{
printf("Error in step: %s\n", sqlite3_errmsg(con));
exit(1);
}
sqlite3_finalize(ins);
stat = sqlite3_prepare(con, SEL, strlen(SEL), &sel, NULL);
if(stat)
{
printf("Error in prepare: %s\n", sqlite3_errmsg(con));
exit(1);
}
while(sqlite3_step(sel) == SQLITE_ROW)
{
printf("%d %s\n", sqlite3_column_int(sel, 0),
sqlite3_column_text(sel, 1));
}
sqlite3_finalize(sel);
sqlite3_close(con);
return 0;
}
$ cc/include=sqlite3_include: test.c
$ link test+sys$input/opt
sqlite3shr/share
$
$ run test
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
3 Hi from C on Windows
4 Hi from Pascal on Windows
5 Hi from Java on Windows
6 Hi from C# on Windows
7 Hi from CLI tool on Windows
8 Hi from CLI tool on VMS
9 Hi from Python on VMS
10 Hi from C on VMS
$ type test.pas
[inherit('sqlite', 'psqlite')]
program test(input, output);
var
con : sqlite_ptr;
ins, sel : sqlite_stmt_ptr;
begin
con := psqlite_open('test.db');
if con = 0 then begin
writeln('Error in open: ', psqlite_errmsg(con));
halt;
end;
ins := psqlite_prepare(con, 'INSERT INTO multi(msg) VALUES(?)');
if ins = 0 then begin
writeln('Error in prepare: ', psqlite_errmsg(con));
halt;
end;
if not psqlite_bind_text(ins, 1, 'Hi from Pascal on VMS') then begin
writeln('Error in bind: ', psqlite_errmsg(con));
halt;
end;
if not psqlite_step_nonquery(ins) then begin
writeln('Error in step: ', psqlite_errmsg(con));
halt;
end;
sel := psqlite_prepare(con, 'SELECT id,msg FROM multi');
if sel = 0 then begin
writeln('Error in prepare: ', psqlite_errmsg(con));
halt;
end;
while psqlite_step_query(sel) do begin
writeln(psqlite_column_int(sel, 0):1, ' ',
psqlite_column_text(sel, 1));
end;
psqlite_finalize(sel);
psqlite_close(con);
end.
$ pas test
$ link test + psqlite/opt + sqlite/opt
psqlite
sqlite
sqlite3shr/share
$ run test
1 Hi from CLI tool on Windows
2 Hi from Python on Windows
3 Hi from C on Windows
4 Hi from Pascal on Windows
5 Hi from Java on Windows
6 Hi from C# on Windows
7 Hi from CLI tool on Windows
8 Hi from CLI tool on VMS
9 Hi from Python on VMS
10 Hi from C on VMS
11 Hi from Pascal on VMS
$ sqlite3 test.db -init test.sql
1|Hi from CLI tool on Windows
2|Hi from Python on Windows
3|Hi from C on Windows
4|Hi from Pascal on Windows
5|Hi from Java on Windows
6|Hi from C# on Windows
7|Hi from CLI tool on Windows
8|Hi from CLI tool on VMS
9|Hi from Python on VMS
10|Hi from C on VMS
11|Hi from Pascal on VMS
12|Hi from CLI tool on VMS
Arne