Skip to content

stevenpack/cloudflare-workers-kv-export

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloudflare-workers-kv-export

Export your Cloudflare Workers KV namespaces to sqlite for querying

Helpful if you need to explore your KV data with SQL, such as joining, extracting JSON values etc.

Installation

npm install

Usage

Usage: node export <config.toml> <apiKey>

Sample config.toml

account_id = "xxx"
auth_email = "[email protected]"
filename = "kv.db"

# You can suppress values being written, such as if values are large
kv-namespaces = [
         { title = "NAMESPACE_1", id = "yyy" },
         { title = "BIG_NAMESPACE_2", id = "zzz", values = "false" },
]

Once you've exported your data, you can query in sqlite using the json function.

For example:

SELECT DISTINCT json_extract(json(val), '$.subscriptions[0].bookId') as bookId
FROM ACCOUNTS
where bookId is not NULL

Features

  • Creates a table in a local sqlite db for each KV Namespace you specify in the toml
  • Paginates keys for namespaces with > 1000 keys
  • Upserts to support re-runs
  • Can get or supress retrieving the values

About

Export your KV namespaces to sqlite for querying

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published