Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 22462

Lintel Technologies: DBSlayer

$
0
0

DBSlayer is a simpler way to proxy mysql.

DBSlayer can be queried via JSON over HTTP, and the responses can be given in either one of the following supported languages : JSON, PHP and Python which makes processing the database results.

Multi-threaded server written in C.

Features :

  • Reduce configuration
  • Reduce dependencies
  • Handle failovers
  • Simple load balancing
  • Easy to monitor
  • Minimal performance overhead
  • Work in different configuration scenarios
  • Support different programming languages

Installing DBSlayer :

git clone https://github.com/derekg/dbslayer.git

./configure

make

make install

Database URI :

http://machine:port/db?URLENCODED(JSON OBJECT)

http://machine:port/dbform?URLENCODED(HTML FORM)

Parameters :

SQL – SQL to execute

Example Request :

http://localhost:9090/dbform?SQL=SELECT+name+FROM+emp

Example Response :

{'RESULT': {'HEADER': ['name'],

'ROWS' : [['name']],

'TYPES' : ['MYSQL_TYPE_VAR_STRING'],

'SERVER' : 'servername'

}}

Example for python :

import urllib2, urllib, json

def dbex():
    uri = 'http://localhost:9090/dbform?SQL=%s'
    data = urllib2.urlopen(uri%urllib.quote('SELECT * FROM market')).read()
    print json.loads(data)

dbex()

Start dbslayer :

dbslayer -c /path/dbslayer.conf -s servername

This starts up a DBSlayer daemon on 9090 (this default port can be changed which acts as a proxy for the backend mysql server. this proxy can be queried via JSON over HTTP).

Stop dbslayer :

pkill dbslayer

Other URI/API endpoints :

http://machine:port/stats [Queries per second]

http://machine:port/stats/log [Last 100 requests]

http://machine:port/stats/errors [Last 100 error]

http://machine:port/shutdown [Only from localhost]

The post DBSlayer appeared first on Lintel Technologies Blog.


Viewing all articles
Browse latest Browse all 22462

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>