liveBook · Manning

SQLite

As explained in DuckDB in Action

SQLite is an embedded relational database library primarily used for transactional data storage in applications.

SQLite is an embedded, weakly typed OLTP database that can be queried from DuckDB when analytical queries benefit from DuckDB’s engine without importing the data into persistent storage. section 5.6 section 5.0

A practical SQLite-to-DuckDB workflow is:

  • Install and load the SQLite extension, then attach the database file. section 5.6
  • Inspect attached tables with PRAGMA show_tables or the .tables command. section 5.6
  • Resolve schema mismatches by scanning tables as VARCHAR and casting columns explicitly in views. section 5.6

Inspect and normalize a player table

Attach the SQLite file, then create a view with explicit types: cast birthday to DATE, height and weight to FLOAT, and identifier columns to BIGINT. Querying the resulting view exposes usable player records and supports joins with Player_Attributes, such as ranking players by their latest overall rating. section 5.6

USE main;
CREATE OR REPLACE VIEW Player AS
FROM sqlite_scan('database.sqlite', 'Player')
SELECT * REPLACE (
  id :: BIGINT AS id,
  player_api_id :: BIGINT AS player_api_id,
  player_fifa_api_id :: BIGINT AS player_fifa_api_id,
  birthday :: DATE AS birthday,
  height :: FLOAT AS height,
  weight :: FLOAT AS weight
);

Use the runnable view definition to convert SQLite’s inferred values into an analytical schema. section 5.6

How DuckDB in Action covers it

How deep it goes
Explains extension loading, attachment, inspection, type mismatches, and view-based casting, but not SQLite internals.
Examples
Uses a 300 MB European soccer SQLite database, Player views, schema inspection, and latest-player-rating queries.
What you can do after
Operate/configure SQLite access through DuckDB, inspect tables, diagnose type mismatches, and build casted analytical views.
How it connects
Connects SQLite with DuckDB, SQL views, schema inference, weak typing, strong typing, and explicit type casting.

Also explained in

Compare how 15 books explain SQLite →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of DuckDB in Action. The section links point to the parts of the book it draws on.