SQLite

This section contains information on the configuration and the data type mapping of SQLite databases. SQLite is an ideal database for embedded applications. This file-based SQL database requires no installation, since it is already integrated in the TwinCAT Database Server. The relational database offers most of the features of SQL databases and supports the commands of the SQL92 standard. The database enables reliable and fast data storage. However, the database does not allow distinction of users. It is therefore particularly suitable for safe storage of variables on the local system.

Declaration in the TwinCAT Database Server Configurator

SQLite database

Database Type

Select "SQLite" from the drop-down menu.

SQLite database file

Enter the name and path of the database. You can also use the browser dialog. If the database does not yet exist, it can be created with the Create button. Corresponding permissions must exist.

Authentication

An option for logging into the database as a particular user.

Password

Enter the corresponding password.

SQLite 1:

Windows CE support

The database is also supported by the Windows CE version of the TwinCAT Database Server, but only on devices with ARM processor. The connection can be established locally.

SQLite 2:

TwinCAT/BSD support

This database is supported by the TwinCAT Database Server on TwinCAT/BSD. In addition, however, the installation of the package "sqlite3" from the package repository is required for use.

Data type mapping between DB and PLC

SQLite has five internal basic data types. For more precise interpretation of the data, additional data types are supported, which are listed in the documentation of the database manufacturer.

E_ColumnTypes

SQLite

TwinCAT PLC

BigInt

BIGINT

T_ULARGE_INTEGER (TcUtilities.lib)

Integer

INT

DINT

SmallInt

SMALLINT

INT

TinyInt

TINYINT

BYTE

Bit_

BOOLEAN

BOOL

Money

DOUBLE

LREAL

Float

FLOAT

LREAL

Real_

REAL

REAL

DateTime

DATETIME

DT

NText

TEXT

STRING

NChar

NCHAR

STRING

Image

BLOB

ARRAY OF BYTE

NVarChar

NVARCHAR

STRING

Binary

BLOB

ARRAY OF BYTE

VarBinary

BLOB

ARRAY OF BYTE

Special feature: string or binary data types are unlimited in Sqlite. However, the TwinCAT 3 Database Server requires fixed limits, which can be set in the general server settings.

SQLite 3:

Incompatible data types

It is possible that incompatible data type designations are created in the database by third-party software, which the TwinCAT3 Database Server cannot interpret. In this case it is helpful to use the SQL Query Builder.

SQLite 4:

Data type support

This database supports the data type WSTRING. (See WString support)

Notice

Data security

In flash memory devices the number of write access operations is limited. The flash memory devices can fail, with a risk of data loss.

  • Make regular backups of your system. Use the IPC diagnostics in order to determine the status of the flash memory devices.