Skip to content

Documentation: Hosting locally. #40

Open
@Fr3akyMurk

Description

@Fr3akyMurk

Greetings.
As you may already know, i have been battling with drizzle, mysql and planetscale, where most of the issues came from SSL errors.

I have found my solution to my problem.
I found out that planetscale uses HTTP / HTTPS to connect to instances, something planetscale supports but not something standard mysql servers do.

so this is my new index.ts file in drizzle that works.

import { drizzle } from "drizzle-orm/mysql2";
import mysql from 'mysql2';

// Create a MySQL connection pool (synchronous operation)

/*
Some options include:
    host: process.env["DATABASE_HOST"],
    user: process.env["DATABASE_USERNAME"],
    password: process.env["DATABASE_PASSWORD"],
    database: process.env["DATABASE_NAME"],
*/

import { env } from "@/env";
import * as schema from "./schema";

const pool = mysql.createPool({
    uri: 'mysql://root:MARIADB@localhost:3306/lucia',
    waitForConnections: true,
    connectionLimit: 10,
    queueLimit: 0
});

export const db = drizzle(pool, { schema, mode: "default" });

I do not care about the connection URI, it's local.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions