![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
cloudflare-mysql
Advanced tools
A Cloudflare Workers compatible MySQL package based on the MySQL Node package.
This is a modification to the MySQL JavaScript package which removes the node dependencies and refactors it for use in Cloudflare Workers.
Alongside the node dependency removals, two polyfills are provided, but only to the point that they're functional in this package. That is to say, they're not 100% polyfill covers, they're only a polyfill for the mysql package.
A major downside is that each request to your worker, will initialize one new connection. Connections cannot be stored in the memory. This will cause a much heavier impact on your MySQL server than if you'd only have server replicas running constantly.
then I advise you strongly to pick a serverless approach, such as Cloudflare D1 (Open Alpha) or Turso: SQLite Developer Experience in an Edge Database.
Using the package is no different than using the original package, all you have to do is remove any dependencies to the previous package:
npm uninstall mysql @types/mysql
And add the this package:
npm install cloudflare-mysql
And change the imports from mysql
to cloudflare-mysql
.
Types are automatically included. The types are the same as @types/mysql, at the forked point. I will continue to provide patches to this package if the original package is at some point updated.
import { createConnection } from "cloudflare-mysql";
export default {
async fetch(request: Request, env: Env, context: ExecutionContext): Promise<Response> {
const url = new URL(request.url);
const searchInput = url.searchParams.get("search");
const result = await new Promise<any>((resolve) => {
const connection = createConnection({
host: "localhost",
user: "root",
password: "password",
database: "database"
});
connection.connect((error) => {
if(error)
throw new Error(error.message);
connection.query("SELECT title FROM articles WHERE title LIKE CONCAT('%', ?, '%')", [ searchInput ], (error, rows, fields) => {
connection.end();
resolve({ fields, rows });
});
});
});
return new Response(JSON.stringify(result, undefined, 4));
}
}
/*
{
"fields": [
{
"catalog": "def",
"db": "developer_blog",
"table": "articles",
"orgTable": "articles",
"name": "title",
"orgName": "title",
"charsetNr": 33,
"length": 765,
"type": 253,
"flags": 4097,
"decimals": 0,
"zeroFill": false,
"protocol41": true
}
],
"rows": [
{
"title": "Restricting a Google Maps API key"
}
]
}
*/
There is also a full worker example that you can try locally or remotely.
FAQs
A Cloudflare Workers compatible MySQL package based on the MySQL Node package.
The npm package cloudflare-mysql receives a total of 1 weekly downloads. As such, cloudflare-mysql popularity was classified as not popular.
We found that cloudflare-mysql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.