SQLGitHub — Managing GitHub organization made easier
SQLGitHub features a SQL-like syntax that allows you to:
Query information about an organization as a whole.
You may also think of it as a better, enhanced frontend layer built on top of GitHub's RESTful API.
- Install prerequisites
pip install requests prompt_toolkit pygments regex
- Install my patched PyGithub
git clone https://github.com/lnishan/PyGithub.git
cd PyGithub
./setup.py build
sudo ./setup.py install
- Configure SQLGitHub (optional)
In root directory (same directory asSQLGitHub.py
),
Create and editconfig.py
:
token = "your token here" # can be obtained from https://github.com/settings/tokens
output = "str" # or "csv", "html"
- Start SQLGitHub
./SQLGitHub.py
→ Get name and description from all the repos in abseil.
select name, description from abseil.repos
→ Get last-updated time and title of the issues closed in the past 3 days in servo listed in descending order of last-updated time.
select updated_at, title from servo.issues.closed.3 order by updated_at desc
→ Get top 10 most-starred repositories in servo.
select concat(concat("(", stargazers_count, ") ", name), ": ", description) from servo.repos order by stargazers_count desc, name limit 10
→ Get top 10 contributors in servo for the past 7 days based on number of commits.
select login, count(login) from servo.commits.7 group by login order by count(login) desc, login limit 10
SELECT
select_expr [, select_expr ...]
FROM {org_name | org_name.{repos | issues | pulls | commits}}
[WHERE where_condition]
[GROUP BY {col_name | expr}
[ASC | DESC], ...]
[HAVING where_condition]
[ORDER BY {col_name | expr}
[ASC | DESC], ...]
[LIMIT row_count]
Most of the fields listed in GitHub API v3 are available for query.
For example, for org_name.repos
queries, you can specify id
, name
, full_name
, description
... etc. in expr's.
You may also use select *
for the full list of fields.
String Functions:
"concat", "concat_ws", "find_in_set", "insert", "instr", "length", "locate", "lcase", "lower", "left", "mid", "repeat", "right", "replace", "strcmp", "substr", "substring", "ucase", “upper"
Numeric Functions:
"avg", "count", "max", "min", “sum", "abs", "ceil", "ceiling", "exp", "floor", "greatest", "least", "ln", "log", "pow", "power", "sign", "sqrt"
Date & Advanced Functions:
"curdate", "current_date", "current_time", "current_timestamp", "curtime", "localtime", "localtimestamp", "now", “bin"