Sqlite3 warnings and errors

Please follow the below template, it will help us to help you!

If you are Experiencing issues with a Pi-hole install that has non-standard elements (e.g you are using nginx instead of lighttpd, or there is some other aspect of your install that is customised) - please use the Community Help category.

Expected Behaviour:

no sqlite3 warnings/errors
-operating system

$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:        10
Codename:       buster
$ uname -a
Linux pi3bp 5.10.17-v7+ #1421 SMP Thu May 27 13:59:01 BST 2021 armv7l GNU/Linux
$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION="10 (buster)"
$ php -v
PHP 7.3.27-1~deb10u1 (cli) (built: Feb 13 2021 16:31:40) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.27, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.27-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies
$ lighttpd -v
lighttpd/1.4.53 (ssl) - a light and fast webserver
$ apt list --installed | grep php

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

php-bz2/stable,now 2:7.3+69 all [installed]
php-cgi/stable,now 2:7.3+69 all [installed]
php-common/stable,now 2:69 all [installed]
php-curl/stable,now 2:7.3+69 all [installed]
php-fpm/stable,now 2:7.3+69 all [installed]
php-intl/stable,now 2:7.3+69 all [installed]
php-mbstring/stable,now 2:7.3+69 all [installed]
php-sqlite3/stable,now 2:7.3+69 all [installed]
php-xml/stable,now 2:7.3+69 all [installed]
php-zip/stable,now 2:7.3+69 all [installed]
php7.3-bz2/stable,now 7.3.27-1~deb10u1 armhf [installed,automatic]
php7.3-cgi/stable,now 7.3.27-1~deb10u1 armhf [installed,automatic]
php7.3-cli/stable,now 7.3.27-1~deb10u1 armhf [installed,automatic]
php7.3-common/stable,now 7.3.27-1~deb10u1 armhf [installed,automatic]
php7.3-curl/stable,now 7.3.27-1~deb10u1 armhf [installed,automatic]
php7.3-fpm/stable,now 7.3.27-1~deb10u1 armhf [installed,automatic]
php7.3-intl/stable,now 7.3.27-1~deb10u1 armhf [installed,automatic]
php7.3-json/stable,now 7.3.27-1~deb10u1 armhf [installed,automatic]
php7.3-mbstring/stable,now 7.3.27-1~deb10u1 armhf [installed,automatic]
php7.3-opcache/stable,now 7.3.27-1~deb10u1 armhf [installed,automatic]
php7.3-readline/stable,now 7.3.27-1~deb10u1 armhf [installed,automatic]
php7.3-sqlite3/stable,now 7.3.27-1~deb10u1 armhf [installed,automatic]
php7.3-xml/stable,now 7.3.27-1~deb10u1 armhf [installed,automatic]
php7.3-zip/stable,now 7.3.27-1~deb10u1 armhf [installed,automatic]

Actual Behaviour:

eg: 2021-06-07 11:09:45: (mod_fastcgi.c.421) FastCGI-stderr: PHP Warning: SQLite3::query(): Unable to prepare statement: 1, no such table: message in /var/www/html/admin/api_db.php on line 402
eg: [2021-06-07 11:13:00.217 2520/T2524] ERROR: SQL query "DELETE FROM network_addresses WHERE lastSeen < 1591499580;" failed: SQL logic error

Debug Token:


Your long term database appears to be corrupted. You can copy it to a new location and start a new database:

sudo service pihole-FTL stop

sudo mv /etc/pihole/pihole-FTL.db /etc/pihole/pihole-FTL-old.db

sudo service pihole-FTL start

@jfb Thank you very much, the snippets works. Appreciate it :slight_smile: