No such table

I've written a simple Workers script locally to get some data from D1
import { Router } from 'itty-router';

const router = Router();

export interface Env {
    kirbyDB: D1Database;
}

router.get('/kirby', async (_, env: Env) => {
    const { results } = await env.kirbyDB.prepare('SELECT * FROM game').all();
    console.log(results);
    return new Response('kirby');
});

export default {
    fetch: router.handle,
};

In wrangler.toml I bind it like this
name = "learn-workers"
main = "src/worker.ts"
compatibility_date = "2023-06-15"

[[d1_databases]]
binding = "kirbyDB"
database_name = "kirby"
database_id = "7d96fcb0-da44-4d95-ae22-8fd7101e7045"

In the Cloudflare Dashboard above I set up the database like this

I think the database should be fine, because I can access it using wrangler
โฏ wrangler d1 execute kirby --command "SELECT * FROM game"

๐ŸŒ€ Mapping SQL input into an array of statements
๐ŸŒ€ Parsing 1 statements
๐ŸŒ€ Executing on kirby (7d96fcb0-da44-4d95-ae22-8fd7101e7045):
๐Ÿšฃ Executed 1 commands in 4.9073589984327555ms
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ console โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ gba     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ sfc     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

But in the script I get this error
[mf:err] Cause: Error: Error: SqliteError: no such table: game  

Did I make a mistake or something?

GitHub Issues link: https://github.com/cloudflare/workers-sdk/issues/3479
246309060-4b1bd848-329f-44c9-a397-b4aa88b6134c.png
GitHub
Which Cloudflare product(s) does this pertain to? D1, Workers/Other, Wrangler What version of Wrangler are you using? 3.1.0 What operating system are you using? Windows 11 Describe the Bug I've...
Was this page helpful?