Giter VIP home page Giter VIP logo

mysql-server's Introduction

mysql-server

This is an experimental implementation of a MergeStat backend for go-mysql-server from DoltHub. The go-mysql-server is a "frontend" SQL engine based on a MySQL syntax and wire protocol implementation. It allows for pluggable "backends" as database and table providers.

Database

When you connect with a MySQL client, the database name you specify will be a reference to a git repository. Currently, this can either be an HTTP(s) URL (https://github.com/mergestat/mergestat) or a path to a repository on disk.

For instance, the following will list all commits from mergestat/mergestat. The repo is cloned to a temporary directory in the container before the query is executed.

mysql --host=127.0.0.1 --port=3306 "https://github.com/mergestat/mergestat" -u root -proot -e "select * from commits"

Example

You can use a MySQL client to connect to the server and execute queries. For instance, the following is a query against the React codebase that produces a chart of unique contributors every month (by author_email), using Arctype:

Example Using Arctype Client

SELECT
    count(DISTINCT author_email),
    YEAR(author_when) AS y,
    MONTH(author_when) AS m,
    DATE_FORMAT(author_when, '%Y-%m')
FROM commits
WHERE parents < 2
GROUP BY y, m
ORDER BY y, m

Tables

  • commits
  • refs
  • files
  • stats

Usage

The easiest way to get started (for now) is probably by building and running a Docker container locally. MergeStat has some build dependencies (such as libgit2), which must be available on your system when compiling (see the Makefile for details).

You can use the included docker-compose.yaml file in this repository by running docker compose up. This will start a MySQL server on port 3306.

You may also run docker build . -t mergestat/mysql-server to produce a docker image you can run like so:

docker run -p 3306:3306 -v ${PWD}:/repo mergestat/mysql-server

Note the -v flag, in the above we're mounting the current directory (assumed to be a git repo) into /repo in the container.

The repo path is specified by the database name used when connecting to the MySQL server. So, in the above, you would connect like so:

mysql --host=127.0.0.1 --port=3306 "/repo" -u root -proot -e "select hash from commits"

Note the password defaults to root. The user/password can be set by supplying the MYSQL_USER and MYSQL_PWD env vars.

TODO

  • Publish pre-built binaries
  • Publish a Docker image

mysql-server's People

Contributors

patrickdevivo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.