Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: Hosting locally. #40

Open
Fr3akyMurk opened this issue Feb 23, 2024 · 1 comment
Open

Documentation: Hosting locally. #40

Fr3akyMurk opened this issue Feb 23, 2024 · 1 comment

Comments

@Fr3akyMurk
Copy link
Contributor

Fr3akyMurk commented Feb 23, 2024

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.

@Fr3akyMurk
Copy link
Contributor Author

@iamtouha Resolves issue #26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant