Bairdy
Bairdy15mo ago

Can you recommend a mysql driver for deno that isn't a complete dead end?

mysql2 port: never updated. mysql driver: doesn't support strings mysql connector from Oracle: no one cares to port to Deno. ALL, I mean ALL I can think about is going back to superb PHP PDO. What a challenge...
17 Replies
TehShrike
TehShrike13mo ago
Did you ever end up finding anything @Bairdy? I'm trying to get it to work but having issues connecting https://discord.com/channels/684898665143206084/684898665151594506/1187550860746698833
Antonio Sampaio
Antonio Sampaio13mo ago
i'm using knex with mysql2 from npm: and it just works
TehShrike
TehShrike13mo ago
does your server have SSL disabled?
Antonio Sampaio
Antonio Sampaio13mo ago
yep (internal only) maybe its something with the ssl implementation and node compat
TehShrike
TehShrike13mo ago
Yeah, probably.
Kevin Whinnery
Kevin Whinnery13mo ago
If the mysql2 npm module isn't working, that's definitely a compatibility issue we should jump on - @toninho do deno if you have a reproduction case we could use to validate, that would be awesome
Antonio Sampaio
Antonio Sampaio13mo ago
i guess @TehShrike can help with a reproduction case
TehShrike
TehShrike13mo ago
yeah, I can try to write up something more thorough, though about half the details are here: https://discord.com/channels/684898665143206084/684898665151594506/1187550860746698833 the rest of the details are: mysql 8.0.35, from the default macOS installer from https://dev.mysql.com/downloads/mysql/ with no my.cnf file. At some point I guess the default mysql settings started requiring TLS Besides passing in (or not) that ssl property to createConnection, I also passed in host, user, database, password Let me know if you want me to try anything else When I try connecting to PlanetScale with ssl: { rejectUnauthorized: false }, I get an error with the message "unavailable: unable to connect to branch tcancv32qlrt" and then "Uncaught Error: read UNKNOWN"
Kevin Whinnery
Kevin Whinnery13mo ago
So if I try to connect to a PlanetScale DB with the options you mention using mysql2 on npm, I should probably see what you are seeing
TehShrike
TehShrike13mo ago
hah, my PlanetScale database was asleep. One moment I am successfully able to connect to PlanetScale with ssl: { rejectUnauthorized: false } I am also able to connect to PS with ssl: { rejectUnauthorized: true } So everything seems cool there. The issue seems to be when connecting to a local database that requires SSL.
Antonio Sampaio
Antonio Sampaio13mo ago
so... are u providing SSL on the local db and the server?
TehShrike
TehShrike13mo ago
I'm not providing a cert, but I am enabling SSL. When connecting to local:
error: Uncaught (in promise) Error: Bad handshake
at Object.createConnection (file:///Users/joshduff/git/photoquoter/node_modules/.deno/mysql2@2.3.3/node_modules/mysql2/promise.js:242:31)
at default (file:///Users/joshduff/git/photoquoter/server/mysql.ts:21:22)
at file:///Users/joshduff/git/photoquoter/server/index.ts:9:32
at eventLoopTick (ext:core/01_core.js:181:11)
error: Uncaught (in promise) Error: Bad handshake
at Object.createConnection (file:///Users/joshduff/git/photoquoter/node_modules/.deno/mysql2@2.3.3/node_modules/mysql2/promise.js:242:31)
at default (file:///Users/joshduff/git/photoquoter/server/mysql.ts:21:22)
at file:///Users/joshduff/git/photoquoter/server/index.ts:9:32
at eventLoopTick (ext:core/01_core.js:181:11)
Kevin Whinnery
Kevin Whinnery13mo ago
Yeah, I feel like now we are in the land of certificate handling, and Deno and Node have different mechanisms of handling SSL handshakes (if indeed Node is able to connect to your local DB)
TehShrike
TehShrike13mo ago
Yes, I am able to connect to the local db with node. I was also to connect to the local db in Deno using this native Deno library: https://github.com/denodrivers/mysql
Kevin Whinnery
Kevin Whinnery13mo ago
Hm, got it.
TehShrike
TehShrike13mo ago
Want me to create an issue?

Did you find this page helpful?