Sign inSign up

cybergarage/go-sqlserver

By cybergarage

•Updated over 1 year ago

Database framework for implementing a MySQL-compatible and a PostgreSQL-compatible server using Go.

Image
Databases & storage
0

1.0K

cybergarage/go-sqlserver repository overview

GitHub tag (latest SemVer) test Go Reference codecov

⁠What is the go-sqlserver?

The go-sqlserver⁠ provides a set of tools and libraries to create custom SQL servers that can handle MySQL and PostgreSQL protocols. It abstracts the complexities of protocol handling, query parsing, and execution, allowing developers to focus on implementing the business logic and data storage mechanisms.

The go-sqlserver⁠ provides a unified implementation framework of authentication and query handlers for both MySQL and PostgreSQL, allowing developers to build custom SQL servers that support both protocols. The framework is designed to be extensible, allowing developers to add custom query handlers, authentication mechanisms, and data storage backends. By using the framework , developers can easily build an SQL server that supports both MySQL and PostgreSQL protocols.

The go-sqlserver⁠ is currently implemented as an in-memory database using SQLite as the default data store. This allows for quick and efficient data operations without the need for an external database server.

⁠Quick Start

⁠Starting go-sqlserver Server

⁠Using Docker image

go-sqlserver⁠ Docker image is the easiest way; if you do not have Docker installed, go there and install it first. To start the standalone server, run the following command:

docker run -it --rm \
 -p 3306:3306 \
 -p 5432:5432 \
 -p 9181:9181 \
 cybergarage/go-sqlserver:latest

⁠Using database clients

The started go-sqlserver listens on the standard ports of the supported PostgreSQL and MySQL database protocols, and you can connect with go-sqlserver using the standard CLI commands.

⁠MySQL

To operate go-sqlserver with the MySQL protocol, use the standard MySQL shell mysql⁠ as follows:

% mysql -h 127.0.0.1
mysql> CREATE DATABASE test;
mysql> USE test;
mysql> CREATE TABLE test (k VARCHAR(255) PRIMARY KEY, v int);
mysql> INSERT INTO test (k, v) VALUES ('foo', 0);
mysql> SELECT * FROM test WHERE k = 'foo';
+------+------+
| k  | v  |
+------+------+
| foo |  0 |
+------+------+
1 row in set (0.00 sec)

go-sqlserver currently supports the MySQL queries in stages. See MySQL⁠ for current support status.

⁠PostgreSQL

To operate go-sqlserver with the PostgreSQL protocol, use the standard PostgreSQL shell psql⁠ as follows:

% psql --host=localhost
> CREATE DATABASE test;
> \q
% psql --host=localhost test
> CREATE TABLE test (k VARCHAR(255) PRIMARY KEY, v int);
> INSERT INTO test (k, v) VALUES ('foo', 0);
> SELECT * FROM test WHERE k = 'foo';
  k  | v 
-----+---
 foo | 0
(1 row)

go-sqlserver currently supports the PostgreSQL queries in stages. See PostgreSQL⁠ for current support status.

Tag summary

Content type

Image

Digest

sha256:d9dc44b07…

Size

341.4 MB

Last updated

over 1 year ago

docker pull cybergarage/go-sqlserver