Skip to content

My latest attempt to have some useful stats tools for our services.

License

Notifications You must be signed in to change notification settings

owainkenwayucl/stats-plus-plus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stats-plus-plus

My latest attempt to have some useful stats tools for our services.

This is a set of tools that can hopefully be used to write useful just in time stats programs to fulfil the arbitrary requirements we sometimes get. I'm basing it on the stuff I did in the tailoredrcstats (https://github.com/UCL-RITS/tailoredrcstats) package with the aim of having a more generic set of stuff.

Requirements

Python

  • Python 3
  • The official mysql connector package

R

  • R
  • RMySQL

Examples

Here's an example of the kind of thing you can do now in R:

source("r/simpletemplate.r")
source("r/dbtools.r")

keys <- genkeys(c("%DB%", "%PERIOD%"), c("thomas_sgelogs", "2017-08"))
query <- templatefile("sql/mean-slowdown-by-user.sql", keys)
data <- dbquery(keys["%DB%"], query)

What's happening here is we are setting some parameters for the mean-slowdown-by-user SQL query, namely which service and the time period (August 2017), using my templating library to put them into the query, passing that query to the database and getting back an R data object which we can do the usual R tricks on.

The equivalent in Python3 looks like this:

import simpletemplate as st 
import dbtools as dbt 

keys = {'%DB%':'thomas_sgelogs', '%PERIOD%':'2017-08'}
query = st.templatefile(filename='sql/mean-slowdown-by-user.sql', keys=keys)
data = dbt.dbquery(db=keys['%DB%'], query=query)

Or even better, in hy:

(import simpletemplate)
(import dbtools)

(setv keys {"%DB%" "thomas_sgelogs" "%PERIOD%" "2017-08"})
(setv query (simpletemplate.templatefile 
                            :filename "sql/mean-slowdown-by-user.sql"
                            :keys keys))
(setv data (dbtools.dbquery :db (get keys "%DB%")
                            :query query))

About

My latest attempt to have some useful stats tools for our services.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published