Fastest JavaScript client for MySQL, with Deno FFI.

Overview

mysql-native

The fastest [1] JavaScript MySQL client.

import { Connection } from "https://deno.land/x/mysql_native/mod.ts";
const conn = new Connection();

conn.connect({
  unixSocket: "/tmp/mysql.sock",
  // ...
  //
  // setup connection pool
  // pool: 3,
});

// -- Connection methods

conn.execute("INSERT INTO test VALUES (1, 'deno')");

const result = conn.query("SELECT * FROM test");
result.all(); // [ [ 1, "deno" ] ]

const iter = conn.query("SELECT * FROM test");
for (const row of iter) {
  row; // [1, "deno"]
}

conn.close();

// -- Prepared statements

const stmt = conn.prepare("INSERT INTO test2 VALUES (?, ?)");

stmt.run(2, "deno");
stmt.all();

stmt.close();

// -- Transactions

const tx = conn.tx((conn) => {
  conn.execute("...");
  return conn.query("...");
});

Features

It exposes a synchronous & minimal API.

A non-blocking async API is planned but for now use the battle tested denodrivers/mysql module.

  • Performance
  • Prepared statements
  • Bind parameters
  • Non blocking API
  • SSL
  • Connection pooling

Benchmarks

mysql_native dispatches almost zero-overhead calls to libmysqlclient using Deno FFI.

image

View source

Low-level API

sys.ts provides direct access to unsafe libmysqlcient API.

import { mysql_stmt_init } from "https://deno.land/x/mysql_native/sys.ts";

const handle = mysql_stmt_init(null);
mysql_real_connect(
  handle,
  encode("host\0"),
  encode("user\0"),
  encode("password\0"),
  encode("db\0"),
  port,
  socket ? encode("socketPath\0") : null,
  0,
);

mysql_real_query(handle, encode("SELECT * FROM test"), 18);
You might also like...

TypeSafe MongoDB Atlas Data API SDK for Deno & Deno Deploy

Atlas SDK atlas_sdk is a TypeSafe MongoDB Atlas Data API SDK for Deno & Deno Deploy Links Docs Import Replace LATEST_VERSION with current latest versi

Dec 26, 2022

🛣️ A tiny and fast http request router designed for use with deno and deno deploy

Rutt Rutt is a tiny http router designed for use with deno and deno deploy. It is written in about 200 lines of code and is pretty fast, using an exte

Dec 10, 2022

A small, but powerful HTTP library for Deno & Deno Deploy, built for convenience and simplicity

A small, but powerful HTTP library for Deno & Deno Deploy, built for convenience and simplicity

Wren Wren is a small, but powerful HTTP library for Deno & Deno Deploy, built for convenience and simplicity. convenient aliases for HTTP responses au

Dec 12, 2022

deno-ja (Deno Japanese community) showcase

Showcase Deno本家よりも気軽に作ったものを公開できるようなShowcaseです。 スクリーンショットの撮影方法 短めのidを決めていただいて、下記のようにスクリプトを実行してください。 deno task screenshot [url] [id] ※エラーが出る場合は、下記を実行してみ

Oct 28, 2022

A command-line tool to manage Deno scripts installed via deno install

🏞️ nublar nublar is a command-line tool to manage your scripts installed via deno install. 🛳️ Installation deno install --allow-read --allow-write -

Dec 26, 2022

Multi-chain defi crypto sniper written in typescript/javascript. Fastest method of sniping with auto-sell and rug prevention features.

Multi-chain defi crypto sniper written in typescript/javascript. Fastest method of sniping with auto-sell and rug prevention features.

CryptoSniper Community Edition Multi-chain defi crypto sniper written in typescript/javascript. Fastest method of sniping with auto-sell and rug preve

Nov 3, 2022

CryptoDappy is the fastest way to get started with Flow.

CryptoDappy is the fastest way to get started with Flow.

Demo application (testnet) Learning hub (start learning here) What's CryptoDappy? CryptoDappy is the fastest way to get started with blockchain develo

Aug 18, 2022

An animation library, built on the Web Animations API for the smallest filesize and the fastest performance

motion-signals A wrapper over Motion One, An animation library, built on the Web Animations API for the smallest filesize and the fastest performance.

Dec 27, 2022

The Omnibookmarks browser extension is the fastest way to open bookmarks

The Omnibookmarks browser extension is the fastest way to open bookmarks

★ Omnibookmarks The Omnibookmarks browser extension is the fastest way to open bookmarks. Just type a keyword into the address bar to quickly open or

Aug 20, 2022
Owner
Deno Drivers
Maintaining correct and interoperable database drivers for the deno runtime. By @notfilippo and @ebebbington
Deno Drivers
[WIP] WebGL API implementation for Deno, built on GLFW using FFI.

Note I'm no longer working on this project because I have just realized macOS does not support OpenGL ES API, and adding Desktop GL backend to this mo

DjDeveloper 14 Jun 11, 2022
Proposal(s) for a stable Deno FFI API

Proposal(s) for a stable API for Deno FFI In this repository I propose a possible stable APIs for Deno FFI. The proposals are split into folders by to

Aapo Alasuutari 6 Dec 5, 2022
Postgres.js - The Fastest full featured PostgreSQL client for Node.js and Deno

?? Fastest full-featured node & deno client ?? ES6 Tagged Template Strings at the core ??‍♀️ Simple surface API ??️ Dynamic query support ?? Chat and

Rasmus Porsager 4.3k Jan 1, 2023
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Opinionated collection of TypeScript definitions and utilities for Deno and Deno Deploy. With complete types for Deno/NPM/TS config files, constructed from official JSON schemas.

Schemas Note: You can also import any type from the default module, ./mod.ts deno.json import { type DenoJson } from "https://deno.land/x/[email protected]

deno911 2 Oct 12, 2022
The fastest way ⚡️ to create sitemap in your Deno Fresh project 🍋

Fresh SEO ??     Quickly creating sitemaps for your Deno Fresh project. Getting Started Run the setup at the root of your project. deno run

Steven Yung 34 Dec 19, 2022
A Deno ORM for MySQL, SQLite, PostgreSQL, MongoDB, GitHub and serverless service like Deta, InspireCloud, CloudBase, LeanCloud

A Deno ORM for MySQL, SQLite, PostgreSQL, MongoDB, GitHub and serverless service like Deta, InspireCloud, CloudBase, LeanCloud.

ʀᴀʏ 5 Dec 15, 2022
This is a simple boilerplate for a Deno website, deployed with Deno Deploy.

Simple Deno Website Boilerplate This is a simple website boilerplate built using Deno and deployed using Deno Deploy. Demo at simple-deno-website-boil

Bruno Bernardino 15 Dec 3, 2022