{"id":17070360,"url":"https://github.com/owainkenwayucl/stats-plus-plus","last_synced_at":"2026-04-16T11:36:01.898Z","repository":{"id":23564655,"uuid":"99339641","full_name":"owainkenwayucl/stats-plus-plus","owner":"owainkenwayucl","description":"My latest attempt to have some useful stats tools for our services.","archived":false,"fork":false,"pushed_at":"2024-04-25T15:47:52.000Z","size":124,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-28T17:25:02.391Z","etag":null,"topics":["hy","python3","r","sql"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/owainkenwayucl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-04T12:11:55.000Z","updated_at":"2024-04-25T15:47:57.000Z","dependencies_parsed_at":"2024-10-14T11:30:45.558Z","dependency_job_id":"a7450bb5-c113-407b-a18c-f60dd5357c41","html_url":"https://github.com/owainkenwayucl/stats-plus-plus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owainkenwayucl%2Fstats-plus-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owainkenwayucl%2Fstats-plus-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owainkenwayucl%2Fstats-plus-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owainkenwayucl%2Fstats-plus-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/owainkenwayucl","download_url":"https://codeload.github.com/owainkenwayucl/stats-plus-plus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245090875,"owners_count":20559298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hy","python3","r","sql"],"created_at":"2024-10-14T11:30:41.056Z","updated_at":"2026-04-16T11:35:56.860Z","avatar_url":"https://github.com/owainkenwayucl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stats-plus-plus\nMy latest attempt to have some useful stats tools for our services.\n\nThis 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.\n\n## Requirements\n\n### Python\n\n* Python 3\n* The official mysql connector package\n\n### R\n\n* R\n* RMySQL\n\n## Examples\n\nHere's an example of the kind of thing you can do now in R:\n\n```R\nsource(\"r/simpletemplate.r\")\nsource(\"r/dbtools.r\")\n\nkeys \u003c- genkeys(c(\"%DB%\", \"%PERIOD%\"), c(\"thomas_sgelogs\", \"2017-08\"))\nquery \u003c- templatefile(\"sql/mean-slowdown-by-user.sql\", keys)\ndata \u003c- dbquery(keys[\"%DB%\"], query)\n```\n\nWhat'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.\n\nThe equivalent in Python3 looks like this:\n\n```Python\nimport simpletemplate as st \nimport dbtools as dbt \n\nkeys = {'%DB%':'thomas_sgelogs', '%PERIOD%':'2017-08'}\nquery = st.templatefile(filename='sql/mean-slowdown-by-user.sql', keys=keys)\ndata = dbt.dbquery(db=keys['%DB%'], query=query)\n```\n\nOr even better, in [hy](http://docs.hylang.org/en/stable/):\n\n```Clojure\n(import simpletemplate)\n(import dbtools)\n\n(setv keys {\"%DB%\" \"thomas_sgelogs\" \"%PERIOD%\" \"2017-08\"})\n(setv query (simpletemplate.templatefile \n                            :filename \"sql/mean-slowdown-by-user.sql\"\n                            :keys keys))\n(setv data (dbtools.dbquery :db (get keys \"%DB%\")\n                            :query query))\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowainkenwayucl%2Fstats-plus-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fowainkenwayucl%2Fstats-plus-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowainkenwayucl%2Fstats-plus-plus/lists"}