# Install MySQL
julia> Pkg.add("MySQL")
julia> using MySQL

# Create a database in mySQL
using MySQL
con = mysql_connect("localhost", "username", "password", "db_name")
command = """CREATE TABLE Employee
             (
                 ID INT NOT NULL AUTO_INCREMENT,
                 Name VARCHAR(255),
                 Salary FLOAT,
                 JoinDate DATE,
                 PRIMARY KEY (ID)
             );"""
mysql_execute(con, command)

# Insert some values
mysql_execute(con, "INSERT INTO Employee (Name, Salary, JoinDate) values 
('Alpha', 25000.00, '2015-12-12'), ('Beta', 35000.00, '2012-18-17), ('Gamma', 50000.00, '2013-12-14');")

# Get SELECT results
command = "SELECT * FROM Employee;"
dframe = mysql_execute(con, command)

# Close connection
mysql_disconnect(con)



### NoSQL
julia> using Mongo, LibBSON

# Create a client connection
julia> client = MongoClient() 

# Get a handle to collection named "test" in database "test".
# Client object, database name, and collection name are stored as variables.
test = MongoCollection(client, "test", "test")

# Insert a document
document = insert(test, Dict("name" => "rahul", "book" => "learning julia"))



### Using JSON
julia> using Requests
julia> using JSON

julia> result = Requests.get("http://httpbin.org/get")
Response(200 OK, 14 headers, 281 bytes in body)

julia> typeof(result)
HttpCommon.Response

julia> fieldnames(result)
8-element Array{Symbol,1}:
 :status  
 :headers 
 :cookies 
 :data    
 :request 
 :history 
 :finished
 :requests

julia> println(result.data)
UInt8[0x7b, 0x0a, 0x20, 0x20, 0x22, 0x61, 0x72, 0x67, 0x73, 0x22, 0x3a, 0x20, 0x7b, 0x7d, 0x2c, 0x20, 0x0a, 0x20, 0x20, 0x22, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x22, 0x3a, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x22, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, 0x68, 0x74, 0x6d, 0x6c, 0x2b, 0x78, 0x6d, 0x6c, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, 0x6d, 0x6c, 0x3b, 0x71, 0x3d, 0x30, 0x2e, 0x39, 0x2c, 0x2a, 0x2f, 0x2a, 0x3b, 0x71, 0x3d, 0x30, 0x2e, 0x38, 0x22, 0x2c, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x22, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x22, 0x2c, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x22, 0x48, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x62, 0x69, 0x6e, 0x2e, 0x6f, 0x72, 0x67, 0x22, 0x2c, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x22, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x6a, 0x6c, 0x2f, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x22, 0x0a, 0x20, 0x20, 0x7d, 0x2c, 0x20, 0x0a, 0x20, 0x20, 0x22, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x33, 0x35, 0x2e, 0x31, 0x38, 0x38, 0x2e, 0x31, 0x34, 0x32, 0x2e, 0x31, 0x36, 0x32, 0x22, 0x2c, 0x20, 0x0a, 0x20, 0x20, 0x22, 0x75, 0x72, 0x6c, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x62, 0x69, 0x6e, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x65, 0x74, 0x22, 0x0a, 0x7d, 0x0a]

julia> typeof(result.data)
Array{UInt8,1}

julia> output = JSON.parse(convert(String, result.data))
Dict{String,Any} with 4 entries:
  "headers" => Dict{String,Any}(Pair{String,Any}("Connection", "close"),Pair{St…
  "args"    => Dict{String,Any}()
  "url"     => "http://httpbin.org/get"
  "origin"  => "35.188.142.162"

julia> output["headers"]
Dict{String,Any} with 4 entries:
  "Connection" => "close"
  "Host"       => "httpbin.org"
  "Accept"     => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=…
  "User-Agent" => "Requests.jl/0.0.0"

julia> result = Requests.post("http://httpbin.org/post"; data = "this is julia")
Response(200 OK, 14 headers, 436 bytes in body)

julia> JSON.parse(convert(String, result.data))
Dict{String,Any} with 8 entries:
  "headers" => Dict{String,Any}(Pair{String,Any}("Connection", "close"),Pair{St…
  "json"    => nothing
  "files"   => Dict{String,Any}()
  "args"    => Dict{String,Any}()
  "data"    => "this is julia"
  "url"     => "http://httpbin.org/post"
  "form"    => Dict{String,Any}()
  "origin"  => "35.188.142.162"

