n00b Q: wrangler / pages d1 env Qs

hello all, attempting to get next-on-pages dev env working with d1, 1. i realized it's defaulting to local, but i am unable to pass the --remote flag, as it throws an error saying its unrecognized:
pgrep workerd | xargs kill && npx wrangler pages dev .vercel/output/static --kv=MY_KV --d1=test --remote --compatibility-flag=nodejs_compat


✘ [ERROR] Unknown argument: remote
pgrep workerd | xargs kill && npx wrangler pages dev .vercel/output/static --kv=MY_KV --d1=test --remote --compatibility-flag=nodejs_compat


✘ [ERROR] Unknown argument: remote
i think its because this is wrangler pages dev and not wrangler dev, but in pages it states to use --local, i tried that as well and it just defaults to local anyway:
> pgrep workerd | xargs kill && npx wrangler pages dev .vercel/output/static --local=false --kv=MY_KV --d1=test --compatibility-flag=nodejs_compat

wrangler dev now uses local mode by default, powered by 🔥 Miniflare and 👷 workerd.
To run an edge preview session for your Worker, use wrangler dev --remote
Your worker has access to the following bindings:
- KV Namespaces:
- MY_KV: MY_KV
- D1 Databases:
- test: local-test (test)
> pgrep workerd | xargs kill && npx wrangler pages dev .vercel/output/static --local=false --kv=MY_KV --d1=test --compatibility-flag=nodejs_compat

wrangler dev now uses local mode by default, powered by 🔥 Miniflare and 👷 workerd.
To run an edge preview session for your Worker, use wrangler dev --remote
Your worker has access to the following bindings:
- KV Namespaces:
- MY_KV: MY_KV
- D1 Databases:
- test: local-test (test)
2. i also realized when i use wrangler commands its defaulting to cloud/non local so i was getting confused between the two envs, how do i set wrangler to target pages-dev env? there doesn't appear to be a --local flag for the d1 commands, also doesn't appear to be a port flag to target the local 8788 env created by pages dev
wrangler --version
⛅️ wrangler 3.5.1
wrangler --version
⛅️ wrangler 3.5.1
not sure if this should go here, in wrangler, or in d1, if anyone has any suggestions super open or if there is a part of the docs i missed please do not hesitate to let me know!
5 Replies
Donnager
DonnagerOP16mo ago
ohhhhhh that would explain so much hehehe, okay cool, great to know! is there a way to get wrangler D1 to talk to local pages? okay i mean like is there a setting for the wrangler d1 {commands} to sync with local, sorry if thats a dumb Q and thats what you meant that they can't be mixed, just wanted to clarify since its running locally just feels like there is a way to tell it to talk to that instance but maybe not okay super unfortunate, but thank you for letting me know! i am not sure how to mark these as resolved, but if there is a mod please go ahead, appreciate the quick replies and thanks again!
kian
kian16mo ago
Just add —local to them
Donnager
DonnagerOP16mo ago
thanks for the suggestion! i am a huge n00b and don't understand:
wrangler d1 list --local

✘ [ERROR] Unknown argument: local
wrangler d1 list --local

✘ [ERROR] Unknown argument: local
is the flag passed another way? when i do wrangler d1 --help i see there are some flags for env and config, also i do see --local as available for some commands like kv:key, but not for d1
kian
kian16mo ago
It doesn’t exist for list since there is no central local store for databases It exists on stuff like execute which you’d use in the same folder as the Worker
Donnager
DonnagerOP16mo ago
okay super fascinating! did not know this! unfortunately i am still not getting them to work together,
wrangler d1 create test_local
[[d1_databases]]
binding = "DB" # i.e. available in your Worker on env.DB
database_name = "test_local"
database_id =
wrangler d1 create test_local
[[d1_databases]]
binding = "DB" # i.e. available in your Worker on env.DB
database_name = "test_local"
database_id =
wrangler d1 execute test_local --file='./schema.sql' --local
✘ [ERROR] Can't find a DB with name/binding 'test_local' in local config. Check info in wrangler.toml...
wrangler d1 execute test_local --file='./schema.sql' --local
✘ [ERROR] Can't find a DB with name/binding 'test_local' in local config. Check info in wrangler.toml...
do i adjust the .toml file to point to local? when you say same folder as the worker, i am doing this at the root level of the next-on-pages directory, should it be nested inside the app directory? the only way i accessed local before was by running code inside one of the page.tsx files, wondering if that is the way, or alternatively just using a api/route as a way to write commands to the DB also thank you so much for the quick reply and sorry to be a nag! if there is a doc to look at please don't hesitate to point me there as well!
Want results from more Discord servers?
Add your server