All Projects → denodrivers → Mysql

denodrivers / Mysql

Licence: mit
MySQL driver for Deno

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Mysql

Mariadb Container
MariaDB container images based on Red Hat Software Collections and intended for OpenShift and general usage. Users can choose between Red Hat Enterprise Linux, Fedora, and CentOS based images.
Stars: ✭ 19 (-89.84%)
Mutual labels:  database, mariadb
Mariadbpp
C++ client library for MariaDB.
Stars: ✭ 76 (-59.36%)
Mutual labels:  database, mariadb
Mysqldump Php
PHP version of mysqldump cli that comes with MySQL
Stars: ✭ 975 (+421.39%)
Mutual labels:  database, mariadb
Dbshield
Database firewall written in Go
Stars: ✭ 620 (+231.55%)
Mutual labels:  database, mariadb
Mysql
Go MySQL Driver is a MySQL driver for Go's (golang) database/sql package
Stars: ✭ 11,735 (+6175.4%)
Mutual labels:  database, mariadb
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 7,712 (+4024.06%)
Mutual labels:  database, mariadb
Ebean
Ebean ORM
Stars: ✭ 1,172 (+526.74%)
Mutual labels:  database, mariadb
Phpmyfaq
phpMyFAQ - Open Source FAQ web application for PHP and MySQL, PostgreSQL and other databases
Stars: ✭ 494 (+164.17%)
Mutual labels:  database, mariadb
Alpine Mariadb
MariaDB running on Alpine Linux [Docker]
Stars: ✭ 117 (-37.43%)
Mutual labels:  database, mariadb
Prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite & MongoDB (Preview)
Stars: ✭ 18,168 (+9615.51%)
Mutual labels:  database, mariadb
Mariadb4j
MariaDB Embedded in Java JAR
Stars: ✭ 579 (+209.63%)
Mutual labels:  database, mariadb
Linq2db
Linq to database provider.
Stars: ✭ 2,211 (+1082.35%)
Mutual labels:  database, mariadb
Typeorm
ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Stars: ✭ 26,559 (+14102.67%)
Mutual labels:  database, mariadb
Ansible Role Mysql
Ansible Role - MySQL
Stars: ✭ 826 (+341.71%)
Mutual labels:  database, mariadb
Denodb
MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno
Stars: ✭ 498 (+166.31%)
Mutual labels:  database, mariadb
Dbbench
🏋️ dbbench is a simple database benchmarking tool which supports several databases and own scripts
Stars: ✭ 52 (-72.19%)
Mutual labels:  database, mariadb
Jet
Type safe SQL builder with code generation and automatic query result data mapping
Stars: ✭ 373 (+99.47%)
Mutual labels:  database, mariadb
Evolve
Database migration tool for .NET and .NET Core projects. Inspired by Flyway.
Stars: ✭ 477 (+155.08%)
Mutual labels:  database, mariadb
Rmariadb
An R interface to MariaDB
Stars: ✭ 86 (-54.01%)
Mutual labels:  database, mariadb
Pomelo.entityframeworkcore.mysql
Entity Framework Core provider for MySQL and MariaDB built on top of MySqlConnector
Stars: ✭ 2,099 (+1022.46%)
Mutual labels:  database, mariadb

deno_mysql

Build Status GitHub GitHub release (Deno)

MySQL and MariaDB database driver for Deno.

On this basis, there is also an ORM library: Deno Simple Orm

欢迎国内的小伙伴加我专门建的 Deno QQ 交流群:698469316

API

connect

import { Client } from "https://deno.land/x/mysql/mod.ts";
const client = await new Client().connect({
  hostname: "127.0.0.1",
  username: "root",
  db: "dbname",
  password: "password",
});

connect pool

Create client with connection pool.

pool size is auto increment from 0 to poolSize

import { Client } from "https://deno.land/x/mysql/mod.ts";
const client = await new Client().connect({
  hostname: "127.0.0.1",
  username: "root",
  db: "dbname",
  poolSize: 3, // connection limit
  password: "password",
});

create database

await client.execute(`CREATE DATABASE IF NOT EXISTS enok`);
await client.execute(`USE enok`);

create table

await client.execute(`DROP TABLE IF EXISTS users`);
await client.execute(`
    CREATE TABLE users (
        id int(11) NOT NULL AUTO_INCREMENT,
        name varchar(100) NOT NULL,
        created_at timestamp not null default current_timestamp,
        PRIMARY KEY (id)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
`);

insert

let result = await client.execute(`INSERT INTO users(name) values(?)`, [
  "manyuanrong",
]);
console.log(result);
// { affectedRows: 1, lastInsertId: 1 }

update

let result = await client.execute(`update users set ?? = ?`, ["name", "MYR"]);
console.log(result);
// { affectedRows: 1, lastInsertId: 0 }

delete

let result = await client.execute(`delete from users where ?? = ?`, ["id", 1]);
console.log(result);
// { affectedRows: 1, lastInsertId: 0 }

query

const username = "manyuanrong";
const users = await client.query(`select * from users`);
const queryWithParams = await client.query(
  "select ??,name from ?? where id = ?",
  ["id", "users", 1],
);
console.log(users, queryWithParams);

transaction

const users = await client.transaction(async (conn) => {
  await conn.execute(`insert into users(name) values(?)`, ["test"]);
  return await conn.query(`select ?? from ??`, ["name", "users"]);
});
console.log(users.length);

close

await client.close();

Logging

The driver logs to the console by default.

To disable logging:

import { configLogger } from "https://deno.land/x/mysql/mod.ts";
await configLogger({ enable: false });

Test

The tests require a database to run against.

docker container run --rm -d -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=true docker.io/mariadb:latest
deno test --allow-env --allow-net=127.0.0.1:3306 ./test.ts

Use different docker images to test against different versions of MySQL and MariaDB. Please see ci.yml for examples.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].