Our SQL

MySQL + Blockchain. Create MySQL cluster using Blockchain replication.

Building of decentralized blockchain application is as easy as coding a web site or a desktop app. Just store data in MySQL DB and OurSQL will do all other work!


How Does It Work

OurSQL server

OurSQL is a standalone server working similarly to mysql server. There is no GUI. It has command line interface and includes a DB proxy to execute SQL transactions. It works ahead of mysql server.
OurSQL communicates with an app and with other OurSQL servers - blockchain nodes.

MySQL Proxy

Part of OurSQL server is a MySQL proxy. Your app would connect to it instead of MySQL server.

Blockchain

Your application executes SQL update commands to store data. OurSQL DB proxy filters all SQL queries and creates blockchain transactions. When there are enough transactions, a block is made.

Cryptocurrency

Cryptocurrency is a side effect of a blockchain process. It is optional, it is not required to use in your applications. But in some cases it can be useful. For example, for "paid" SQL transactions to add more reliability.

Cluster nodes

Blockchain is only useful when there are many nodes upporting your decentralized DB. OurSQL does all work for data exchange between nodes, to send tranactions and blocks between them. You only need to point new node to one of running nodes to import current DB.


Try OurSQL

Try with docker image

The image name on the docker hub is oursql/oursql-server
docker run --name oursql -p 8766:8766 -d -it oursql/oursql-server
mysql -h 127.0.0.1 -P 8766 -u blockchain -pblockchain BC
> CREATE TABLE test (a int unsigned primary key auto_increment, b varchar(100));
> INSERT INTO test SET b='row1';
              
OR Run 2 nodes and see how DB is replicated
docker run --name oursql1 -p 9001:8765 -p 9002:8766  -d -it oursql/oursql-server interactiveautocreate -port 9001
# pause for 4-5 seconds to allow it to init a blockchain
docker run --name oursql2 -p 9003:8765 -p 9004:8766  -d -it oursql/oursql-server importfromandstart -port 9003 -nodeaddress host.local.address:9001
# pause 3-4 seconds to import blockchain
# connect to the first node proxy
mysql -h 127.0.0.1 -P 9002 -u blockchain -pblockchain BC
# connect to the second node proxy
mysql -h 127.0.0.1 -P 9004 -u blockchain -pblockchain BC
# create tables, do SQL updates, see how data are replicated
              
Read more on how to test OurSQL with docker image
docker pull oursql/oursql-server

Compile OurSQL

You need to have basic experience with Golang programming language
go get github.com/gelembjuk/oursql
# or
git clone git@github.com:Gelembjuk/oursql.git

# install dependencies
go get github.com/go-sql-driver/mysql
go get github.com/JamesStewy/go-mysqldump
go get github.com/btcsuite/btcutil
go get github.com/fatih/structs
go get github.com/mitchellh/mapstructure

cd $GOPATH/src/github.com/gelembjuk/oursql/node
go build

# start OurSQL
./node

# init new blockchain , mysql should be running , in our example there is used the DB named BC and the user blockchain/blockchain
./node createwallet
./node initblockchain -minter YOUR_WALLET_ADDRESS  -mysqluser blockchain -mysqlpass blockchain -mysqldb BC
              
Read more about how to test and use OurSQL
https://github.com/gelembjuk/oursql

OurSQL documentation

We will release documentation soon. For now you can use some manuals on OurSQL github

Download OurSQL presentation


Blockchain consensus configuring for OurSQL

Every blockchain DB must have consensus rules working on every node.

Current version supports only Proof of Work consensus type. Every blockchain has a consensus config file which containes rules. Options of PoW: block hash options, coins to add for minter, numbers of transactions per block etc.

This file is distributed as part of a package instalation package.
Also, in this file it is possible to describe which SQL operation are allowed in this decetralized DB: insert, update, delete , table create. Additionally, it is possible to set rules per table.
Finally, it is possible to set a cost of SQL query per table and type. For example, 0.5 (of a coin) per insert in a table "members". This allows to control updates.

Read more info about OurSQL blockchain consensus support


Where to use OurSQL

OurSQL is a quick way to create a private blockchain. "Private" means brand new blockchain DB, not connected to any well known "public" blockchains, like Ethereum or Bitcoin. With OurSQL it is possibleto start new private blockchain quickly without requirement to have deep understanding of how blockchain works.
To make your private blockchain you need to code some client application that will work with a single local MySQL DB. OurSQL will do all communication between instances of the app (nodes) and support a DB replication with blockchain.

Use OurSQL for cases when you need to have a decentralized Databases with some information controlled by all users without any special any special trust server or so.

Author

Roman Gelembjuk

Contact me if you have questions about the OurSQL project


Our SQL

Follow for updates