Need a javascript example for using Planetscale with schedule function

I’ve gotten planetscale working just fine with my app, now I have a need for a schedule function and I can get this working just fine with netlify dev, however whenever I push to production I encounter problems. The documentation only shows the planetscale integration using the withPlanetscale call as a typescript example.

Does someone have a javascript example I can see?

Here is my simplified test that works with netlify dev locally:

File: players.js

import "dotenv/config";
import { connect } from "@planetscale/database";

const DBConfig = {
  host: process.env.PLANETSCALE_HOST,
  username: process.env.PLANETSCALE_USERNAME,
  password: process.env.PLANETSCALE_PASSWORD,
const conn = connect(DBConfig);

export const handler = async () => {
  const { rows } = await conn.execute("SELECT * FROM players");
  console.log([...rows].map((player) => player.last_name));
  return { statusCode: 200 };

And the output:

Request from ::1: GET /.netlify/functions/players
  'Thomas',       'Stewart', 'Wilson',
  'Howard',       'Parker',  'Howard',
  'Delle Donne',  'Austin',  'Jones',
  'Smith',        'Griner',  'Gray',
  'Taurasi',      'Sabally', 'Magbegor',
  'Vandersloot',  'Smith',   'Williams',
  'Collier',      'Gray',    'Shepard',
  'Ogwumike',     'Boston',  'Wheeler',
  'Juhász',       'Brown',   'Onyenwere',
  'Horston',      'Russell', 'Jones',
  'Gustafson',    'Cloud',   'Sykes',
  'Hawkins',      'Hamby',   'McCowan',
  'Stevens',      'Atkins',  'Fankam Mendjiadeu',
  'Ogunbowale',   'Coffey',  'Bonner',
  'Ionescu',      'Canada',  'Whitcomb',
Response with status 200 in 233 ms.

When pushing to netlify and trying to run it, here are the errors I receive:

An unhandled error in the function code triggered the following message:

Runtime.ImportModuleError - Error: Cannot find module '/var/task/node_modules/@planetscale/database/dist/cjs/index.js'

Stack trace
Runtime.ImportModuleError: Error: Cannot find module '/var/task/node_modules/@planetscale/database/dist/cjs/index.js'
    at _loadUserApp (file:///var/runtime/index.mjs:997:17)
    at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1029:21)
    at async start (file:///var/runtime/index.mjs:1192:23)
    at async file:///var/runtime/index.mjs:1198:1
Connection details
Netlify internal ID: 01H7JFEES5S89FC919Y7DS9PKW

Does adding the following in your netlify.toml:

  included_files = ["./node_modules/@planetscale/database/**/*"]

fix that for you?

It does not, I received the very same error as previously posted.

Mind putting that together in a repository and share it so we can check?

In the process of setting up a repo I realized I had a typo in my .toml file. Your suggestion to add:

worked like a charm.

It would be worth updating the documentation for Planetscale integration to provide this guidance. I had tried previously adding “@planetscale/database” but did not include the wildcards which fixed my issue.

Thanks for the help.