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

Mysql2 type error when trying to query connection #27

Open
Puetz opened this issue Oct 18, 2024 · 1 comment
Open

Mysql2 type error when trying to query connection #27

Puetz opened this issue Oct 18, 2024 · 1 comment

Comments

@Puetz
Copy link

Puetz commented Oct 18, 2024

Hi,

I want to use the mysql2 npm package with Deno 2.

I installed the package using the npm prefix and am able to import it just fine. When I try to run any query on my database connection I'm getting a typescript error "Property 'query' does not exist on type 'Connection'".

I looked at the example in this repo as well as the official mysql2 documentation and I can't figure out what I'm doing wrong.

deno.json

{
    "name": "@scope/deno-backend",
    "version": "0.1.0",
    "exports": "./main.ts",
    "tasks": {
        "dev": "deno run --watch main.ts"
    },
    "imports": {
        "mysql2": "npm:mysql2@^3.11.3"
    }
}

main.ts

import mysql from "mysql2/promise";

const connection = await mysql.createConnection({
    host: "localhost",
    user: "user",
    password: "password",
    database: "react19_db",
});

const results = await connection.query("SELECT * FROM `test`");

If I did something wrong during my setup, then I'm really sorry. It's my first time using Deno 2.

Cheers,
Thomas

@acrodrig
Copy link

Having the same issue. I believe it's because of version:

import mysql from "npm:mysql2@^2.3.3/promise";

Can the example use a newer version of mysql2 package? Version 2.3.3 is more than 5 years old.

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

2 participants