Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards
of acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies
when an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at **a_vision@hotmail.co.uk**. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0,
available at https://www.contributor-covenant.org/version/2/0/
code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at https://
www.contributor-covenant.org/translations.
106 changes: 106 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Contributing to sqlquerygraph
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:

- Reporting a bug
- Discussing the current state of the code
- Submitting a fix
- Proposing new features
- Becoming a maintainer

## We develop with Github
We use github to host code, to track issues and feature requests, as well as accept pull requests.

## We use [Github Flow](https://guides.github.com/introduction/flow/index.html), so all code changes happen through Pull Requests
Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:

1. Fork the repo and create your branch from `master`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
5. Make sure your code lints.
6. Issue that pull request!

## Any contributions you make will be under the MIT Software License
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.

## Report bugs using Github's [Issues](https://github.com/avisionh/sqlquerygraph/issues)
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/avisionh/sqlquerygraph/issues); it's that easy!

## Write bug reports with detail, background, and sample code
[This is an example](http://stackoverflow.com/q/12488905/180626) of a bug report written, and it's not a bad model. Here's [another example from Craig Hockenberry](http://www.openradar.me/11905408).

**Great Bug Reports** tend to have:

- A quick summary and/or background
- Steps to reproduce
- Be specific!
- Give sample code if you can. [A stackoverflow question](http://stackoverflow.com/q/12488905/180626) includes sample code that *anyone* with a base R setup can run to reproduce what I was seeing
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)

People *love* thorough bug reports. I'm not even kidding.

***

## Use a consistent Python coding style
We use [black](https://black.readthedocs.io/en/stable/). The [pre-commit hooks](./.pre-commit-config.yml) also formats any Python code automatically.
* Tabs or four spaces for indentation
* Name your objects explicity, be descriptive

***

## Use a consistent Git messaging structure
More detail is available on the repo's wiki, [House Styles: Git](https://github.com/avisionh/sqlquerygraph/wiki/House-Styles:-Git), but in short.

### Branch
+ **Principle**: Each branch should have a single purpose.
+ **Frequency:** Every time you want to work on part of a project, create a branch for it.
+ **Naming Convention**:
- `type/name` - this lets branches of the same type be grouped together in VSTS
- Choose short and descriptive names

```
Note this is not an exhaustive list:

feature Additional functionality or features
devops Software development/IT operation-related changes
bugfix Fixing an error
data Updating data or data connections
format Changing the format/layout
document Create documents for community standards

Any suggestions, let us know!
```

### Commit
+ **Principle**: Include "what the commit does" as well as "why it does it" if the "what the commit does" message is not sufficient. Like Twitter, any commit message cannot be longer than 80 characters.
+ **Frequency:** Commit often and early, to ensure you don't lose any work. Don't worry about your `git log` or `git nl` looking ugly. You can clean this up afterwards.
+ **Naming Convention**: Should follow the below form, where *<type*> and *<subject*> are mandatory, whilst *<body*> and `*<footer*> are optional.
- If *<body*> and *<footer*> are present, *<BLANK LINE*> is mandatory.

```
<type>: <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```

Most commits can be of the form `<type>: <subject>`.

```
feat A new feature
fix A bug
docs Documentation only changes
style Changes that do not affect the meaning of the code *e.g. white-space, formatting*
refactor A code change that neither fixes a bug or adds a feature
perf A code change that improves performance
test Add missing tests
chore Changes to build process or auxiliary tools and libraries such as documentation generator
```

***

## References
This document was adapted from the open-source contribution guidelines for [Facebook's Draft](https://github.com/facebook/draft-js/blob/a9316a723f9e918afde44dea68b5f9f39b7d9b00/CONTRIBUTING.md)
File renamed without changes.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ Currently, we implement the ability of representing how each of the tables in a

## Requirements
To run the code in here, ensure your system meets the following requirements:
- Unix-like operating system (macOS, Linux, ...);
- [`direnv`](https://direnv.net/) installed, including shell hooks;
- [`.envrc`](https://github.com/avisionh/sqlquerygraph/blob/main/.envrc) allowed/trusted by `direnv` to
use the environment variables - see [below](#allowingtrusting-envrc);
- Unix-like operating system (macOS, Linux, ...) - though it might work on Windows;
- Python 3.8 or above; and
- [Poetry](https://python-poetry.org/docs/) installed.
<!--
- [`direnv`](https://direnv.net/) installed, including shell hooks;
- [`.envrc`](https://github.com/avisionh/sqlquerygraph/blob/main/.envrc) allowed/trusted by `direnv` to use the environment variables - see [below](#allowingtrusting-envrc);
-->

Note there may be some Python IDE-specific requirements around loading environment variables, which are not considered here.
<!--Note there may be some Python IDE-specific requirements around loading environment variables, which are not considered here. -->

### Set-up
For quickstart set-up of the project, run the below in your shell/terminal:
Expand Down Expand Up @@ -56,7 +57,14 @@ We use [neo4j](https://neo4j.com/) for this project to visualise the dependencie
username: neo4j
password: neo4j
```
You can leave the other fields blank. neo4j will then prompt you to change your password. Change it to whatever you please.
You can leave the other fields blank. neo4j will then prompt you to change your password. Change it to whatever you please and the new password will persist the next time you run neo4j locally.
1. When you have finished playing with your local neo4j instance, remember to stop it running by executing the below in your shell/terminal:
```shell script
# find name of container running
docker ps
# stop container running
docker stop sqlquerygraph_neo4j_1
```

***

Expand Down
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ services:
- ./logs:/logs
- ./plugins:/plugins
environment:
NEO4j_dbms.security.auth_enabled: 'true'
NEO4j_AUTH: 'neo4j/neo4j'
# Raise memory limits
- NEO4J_dbms_memory_pagecache_size=2G
- NEO4J_dbms.memory.heap.initial_size=2G
- NEO4J_dbms_memory_heap_max__size=2G
NEO4J_dbms_memory_pagecache_size: 2G
NEO4J_dbms.memory.heap.initial_size: 2G
NEO4J_dbms_memory_heap_max__size: 2G
14 changes: 14 additions & 0 deletions guide/module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### Module arguments
In the Python module example run to extract and export to `.csv` the table names and dependencies of `.sql` scripts:
```shell script
python sqlquerygraph.py -sd 'sql' -ed 'neo4j' -rd 'github_repos' 'analytics' 'reporting'
```
More arguments can be specified to provide greater customisation. They are:

| Argument - short | Argument - long | Description | Required |
|------------------|-----------------|-------------| -------- |
| `-sd` | `--script_dir` | Directory where we store subdirectories of our SQL queries. | True |
| `-d` | `--sub_dir` | Subdirectories within script_dir that you want to read SQL queries from. If no value is inputted, then use all subdirectories in script_dir. | False |
| `-rd` | `--reference_datasets` | Datasets that contain tables in database to look-up against. | True |
| `-ed` | `--export_dir` | Directory to store files. | True |
| `-v` | `--verbose` | Boolean to output steps taken and query after cleaning. Useful if want to check where function is failing. If no value is inputted, then it is False. " | False |