SQLite database

Structure

Database file(s) (main/temp/attached) → Tables/Objects

  • Database: SQLite is just a single-file database. When you connect, you are in one database. There’s no concept of multiple independent databases inside one connection.

  • Schema: There is no concept of "schema" in SQLite, but it can be simulated by "attaching" databases. SQLite supports:

    • main (the connected file)

    • temp (temporary objects)

    • any attached databases (via ATTACH DATABASE 'file2.db' AS otherdb;)

    These act "like schemas" in terms of naming (main.table1, otherdb.table2), but they’re really separate database files.

Telosys typical configuration for a SQLite database

  - id: sqlite
    name: SQLite database 
    type: SQLITE 
    # JDBC config 
    driver: org.sqlite.JDBC
    url: jdbc:sqlite:D:\Z\DB-DATA\SQLite-data\sqlite-db-example.db
    # user: 
    # password: 
    # Metadata parameters
    tableNamePattern: '%'
    tableTypes: TABLE

JDBC driver

Download from https://github.com/xerial/sqlite-jdbc

JAR file example: sqlite-jdbc-3.50.3.0.jar

Notes

  • Authentication: By default, SQLite databases are just files (.db or .sqlite) on disk. Anyone who can read/write the file has full access to the database.

  • No "catalog" and "schema" There is no concept of schema and catalog in SQLite When Telosys retrieves the database model, 'catalog' and 'schema' are always 'null'.

  • In-memory database It's possible to work only "in-memory". The database exists only in RAM, not on disk. To do so use JDBC URL like this: "jdbc:sqlite::memory:" NB: duration=connexion, as soon as the connection is closed, the entire database (all tables) disappears. SQLite supports a mode that allows multiple connections to share the same in-memory database: "jdbc:sqlite:file:memdb1?mode=memory&cache=shared" it will create an in-memory database named "memdb1" (this will not create any files on disk) But even with this mode a shared in-memory database only exists while at least one connection to it is still open. As soon as the last connection closes, SQLite frees the memory, and all tables vanish.

Last updated