liveBook · Manning

SQLite command-line interface

As explained in Data Analysis with LLMs

The SQLite command-line interface is an interactive program for creating, querying, and managing SQLite databases through text commands.

The SQLite command-line interface lets you create a database and load data for analysis. For a video-game dataset, run `sqlite3 games.db` in a terminal to create and open the database. section 5.2.1

Set up the data in three steps:

  • Define a `games` table, listing each column and its type, such as `int` for numbers and `text` for text. section 5.2.1
  • Set CSV mode and import the dataset from its file path into the `games` table. section 5.2.1
  • Check the imported data by querying the number of rows with `SELECT count(*) FROM games;`. section 5.2.1
CREATE TABLE games(             #1
rank int, name text, platform text,                    #2
year int, genre text, publisher text, americasales numeric, 
eusales numeric, japansales numeric, othersales numeric, 
globalsales numeric);

See the example table definition, including columns for game titles, platforms, genres, and sales. section 5.2.1

.mode csv                           #1
.import /Downloads/videogames.csv games  #2

See the commands for switching to CSV mode and importing the file. section 5.2.1

How Data Analysis with LLMs covers it

How deep it goes
Walks through creating a database, defining a table, importing a CSV, and checking its row count.
Examples
Uses a video-game dataset, a `games` table, a CSV file, and a row-count query.
What you can do after
Operate the SQLite CLI to create a database, load a CSV dataset, and check that rows were imported.
How it connects
Connects SQLite databases with SQL table definitions, CSV imports, and structured data analysis.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Analysis with LLMs. The section links point to the parts of the book it draws on.