DataMosaic

Blog · System pairs

SQLite vs Snowflake: what each is for, and proving they agree

One is a library that keeps a database in a single file, the other a warehouse you rent by the second. What each is for, and how to prove the store files and the warehouse hold the same day.

#Two different jobs

People search "SQLite vs Snowflake" as if they had to pick one. They rarely do. SQLite's own documentation puts it plainly: "SQLite does not compete with client/server databases." It "competes with fopen()", meaning it replaces the files an application would otherwise write for itself. Snowflake is at the other end: a service you don't install, which holds a whole organisation's data and runs queries on compute you rent.

So the useful question is which job each does, and what happens where they meet. In retail they meet often: a till, a handheld or a store back-office app keeps its day in a SQLite file, and every night that day is loaded into Snowflake, where finance and merchandising read it.

#Side by side

Every line below comes from SQLite's or Snowflake's own documentation.

SQLiteSnowflake
What it isA library "built into the application". No server, no administrationA cloud service. Snowflake runs the hardware and software; it cannot be installed on your own servers
Where data livesOne ordinary file on the deviceSnowflake's cloud storage, in a compressed columnar format, on AWS, Azure or Google Cloud
Writers at once"An unlimited number of simultaneous readers", but "only one writer at any instant in time" per fileMost INSERT and COPY statements can run in parallel; UPDATE, DELETE and MERGE lock the table they change
SizeUp to 281 TB per file, if your disk allows itStorage grows with what you load; compute comes from virtual warehouses you size, and multi-cluster warehouses (Enterprise Edition) add clusters for concurrency
Across a networkAvoid it where "the same database will be accessed directly ... and simultaneously from many computers over a network"Built for it: every client connects over the network
CostPublic domain, no licence. You pay for the device it runs onCompute in credits, billed per second with a 60-second minimum each time a warehouse starts; storage at a flat rate per TB per month; data leaving a region or cloud is charged
TypesDynamic: "the datatype of a value is associated with the value itself". No date type and no decimal typeStrict: NUMBER(p,s) holds exact decimals, DATE has no time, TIMESTAMP means TIMESTAMP_NTZ by default

Sources: SQLite's pages on when to use it, data types and copyright; Snowflake's key concepts, cost, transactions and warehouses.

#Which one for which job

Use SQLite when one application owns the data and runs on one machine: a till that must keep selling when the line to head office is down, a handheld that counts stock in the stockroom, a desktop tool. It needs no server and no one to look after it, and a whole store's day is one file you can copy.

Use Snowflake when many people need to query data from many sources: every store's sales next to the ERP, the web shop and the loyalty system, read by people who never see a till. You pay for compute while queries run, and Snowflake keeps the service upgraded.

A chain usually has both, and the risk sits between them. A store's file can fail to arrive, a nightly load can stop half way, and a type can change on the way in.

#Where the two disagree

Three traps make the same day look different on each side.

Amounts. SQLite has no decimal type. A column declared DECIMAL(12,2) gets numeric affinity and the precision is ignored, so a till can store 12.995 and SQLite keeps it. If the load into a Snowflake NUMBER(12,2) column rounds each line, the totals drift by a few cents across a day. SQLite's own aggregate page warns that sum() over floating point values "is an approximation", so round the total before you compare it.

Dates. SQLite keeps dates as text, a number of days or a Unix time, whichever the app chose. If the app wrote 2026-11-12 23:58:10 and the load cuts at UTC midnight, a late sale lands on the next business day in Snowflake. Compare on the business date the till wrote, never on a timestamp converted on the way.

Names. Snowflake folds net_amount to NET_AMOUNT unless it was created with quotes. A load that created "net_amount" in quotes will make every unquoted query fail with an invalid identifier.

#The check: count and total per store and day

Rows don't help until the totals agree. Ask each side the same two questions for one business date: how many lines, and what total.

In each store's SQLite file, from the sqlite3 command-line shell:

SELECT business_date,
       COUNT(*)                                        AS line_count,
       CAST(ROUND(TOTAL(net_amount) * 100) AS INTEGER) AS net_cents
FROM sales_line
WHERE business_date = '2026-11-12'
GROUP BY business_date;

TOTAL() rather than SUM() because SQLite documents that total() returns 0.0 for no rows, where sum() returns NULL. Working in cents turns both sides into whole numbers, so nothing is compared as floating point.

In Snowflake, the same question for every store at once:

SELECT store_code,
       COUNT(*)                                       AS line_count,
       CAST(ROUND(SUM(net_amount) * 100) AS INTEGER)  AS net_cents
FROM sales.store.sales_line
WHERE business_date = '2026-11-12'
GROUP BY store_code
ORDER BY store_code;

Run it on an X-Small warehouse. Snowflake's table gives X-Small one credit an hour on first-generation standard warehouses, and the query takes seconds.

#A script that does every store

With 120 stores, nobody opens 120 files. This Python script reads every store file in a folder, read-only, asks Snowflake once, and prints one line per store. It needs Python 3 and pip install snowflake-connector-python; sqlite3 is in the standard library.

import os
import sqlite3
from pathlib import Path

import snowflake.connector

DAY = "2026-11-12"
FOLDER = Path("store-files")   # one file per store: ST-004.db, ST-014.db ...
TOLERANCE_CENTS = 5

# One count and total per store file, opened read-only
tills = {}
for path in sorted(FOLDER.glob("ST-*.db")):
    con = sqlite3.connect(path.resolve().as_uri() + "?mode=ro", uri=True)
    lines, cents = con.execute(
        "SELECT COUNT(*), CAST(ROUND(TOTAL(net_amount) * 100) AS INTEGER) "
        "FROM sales_line WHERE business_date = ?",
        (DAY,),
    ).fetchone()
    con.close()
    tills[path.stem] = (int(lines), int(cents))

# The same per store from Snowflake, in one query
con = snowflake.connector.connect(
    account=os.environ["SF_ACCOUNT"],
    user=os.environ["SF_USER"],
    password=os.environ["SF_PASSWORD"],
    role="RECON_READER",
    warehouse="RECON_XS",
    database="SALES",
    schema="STORE",
)
cur = con.cursor()
cur.execute(
    "SELECT store_code, COUNT(*), CAST(ROUND(SUM(net_amount) * 100) AS INTEGER) "
    "FROM sales_line WHERE business_date = %s GROUP BY store_code",
    (DAY,),
)
warehouse = {row[0]: (int(row[1]), int(row[2])) for row in cur.fetchall()}
con.close()


def show(side):
    return "none" if side is None else f"{side[0]:>5} {side[1] / 100:>12,.2f}"


for store in sorted(set(tills) | set(warehouse)):
    t, s = tills.get(store), warehouse.get(store)
    if t is None:
        result = "No file from the store"
    elif s is None:
        result = "Missing in Snowflake" if t[0] else "Closed, nothing to load"
    elif abs(t[1] - s[1]) > TOLERANCE_CENTS:
        result = f"Total differs, {(t[1] - s[1]) / 100:,.2f}"
    elif t[0] != s[0]:
        result = "Line count differs"
    elif t[1] != s[1]:
        result = "Rounding, within 0.05"
    else:
        result = "Agrees"
    print(f"{store:8} {show(t):>20} {show(s):>20}  {result}")

Three things it does on purpose. mode=ro opens each file read-only, which SQLite's URI page defines, so the check can never write to a store's data. The tolerance is written down, five cents, rather than decided each morning. And a store with no file is its own result, because "the file never came" and "the load lost it" have different fixes.

#The worked example

An invented chain of 120 stores. Each store's back-office app keeps its sales lines in SQLite; every night the files are copied to head office and loaded into Snowflake. The script above, run for 12 November, on seven of the stores:

StoreLines, SQLiteTotal, SQLiteLines, SnowflakeTotal, SnowflakeResult
ST-0044129,850.204129,850.20Agrees
ST-0112887,301.402887,301.40Agrees
ST-01453012,400.0051211,920.00Total differs, 480.00
ST-0222516,410.75nonenoneMissing in Snowflake
ST-0313448,120.003448,119.96Rounding, within 0.05
ST-0371995,214.601995,214.60Agrees
ST-047nonenone962,392.30No file from the store

Invented figures. Three stores agree. ST-014 lost 18 lines worth 480.00 on the way in: the load rejected them. ST-022's file arrived but its rows never reached the warehouse. ST-031 is the decimal trap: the till stores line amounts to three places and the load rounds each line to two, so 344 lines lose 0.04. ST-047 sent no file last night, yet Snowflake holds 96 lines for the day: something loaded them another way, perhaps a file sent by hand, and that is worth a call before anyone trusts the store's week.

Across these seven stores the day differs by 4,498.49, and that number alone points nowhere. One line per store does.

#Where doing it by hand runs out

The script tells you which stores. It doesn't tell you why ST-014's 18 lines were refused, it doesn't run itself at six, and tomorrow someone has to remember that ST-031 is always a few cents out.

DataMosaic connects to both. Its SQLite connection reads a file on the machine running Mosaic, opened read-only by default, so the store files are collected there first. Snowflake connects by account identifier, with the warehouse, database, schema and role you choose. A check lines the two sides up on shared keys, store and business date, and shows matched, differing and missing rows; its rules say what counts as a failure, such as more than five cents apart. A date parameter set to YESTERDAY means a nightly check needs no editing, and a trigger runs it on a schedule. On a differing row, an investigation walks through the reasons the two can disagree, such as a load that refused lines or a file that never arrived. A check only reads; Mosaic changes a system only through a workflow you build, such as loading the store's file again and running the check after it.

For the same proof between two engines on servers, see the post on comparing SQL Server and Oracle, and for counts, sums and hashes on every load, the post on reconciliation in ETL.

#Questions people ask

#Is SQLite a replacement for Snowflake?

No. SQLite is a library that keeps one application's data in one file on one machine, and its documentation says it does not compete with client/server databases. Snowflake is a cloud warehouse many users and systems query at once.

#Can Snowflake read a SQLite file directly?

Snowflake's documentation on loading local files describes uploading data files to a stage with PUT and loading them with COPY INTO, and says nothing about SQLite files. Export the tables from SQLite to a file format Snowflake loads, such as CSV, then load that.

#Can several people write to a SQLite database at once?

Many can read at once, but SQLite allows one writer per file at any moment. Writes usually take milliseconds, so a few writers can take turns, but many computers writing over a network is the case SQLite's documentation tells you to avoid.

#Why don't my totals match between SQLite and Snowflake?

Usually amounts or dates. SQLite has no decimal type, so lines stored with three decimals drift when the load rounds them to two, and dates stored as timestamps can land on a different business day after a time zone conversion. Compare a count and a rounded total per store and business date first.

#How much does Snowflake cost compared with SQLite?

SQLite is in the public domain and costs nothing to use. Snowflake bills compute in credits, per second with a 60-second minimum each time a warehouse starts, and storage at a flat rate per terabyte per month. The cost of compute is the credits used multiplied by the price of a credit.

Stop comparing exports by hand.

DataMosaic checks the systems themselves overnight, tells you why they differ, and runs the fix you've set up, before anyone else notices.