Last active
September 18, 2018 05:35
-
-
Save SimonGoring/d46b3f4aa56184d01b7bf25066bcf349 to your computer and use it in GitHub Desktop.
IPython Notebook for BAIT Group Project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"host": "localhost", | |
"port": 5432, | |
"database": "yourdatabase", | |
"user": "postgres", | |
"password": "postgres" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Project Report" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
``` | |
## About the Data | |
We obtained the data from this resource. This is what it represents, these are the basic features. | |
## Data Model | |
The data is modeled in this way. This is how elements relate to one another generally. This is the justification. | |
### Table Descriptions | |
#### Table One | |
The table contains these features, this is what each one of them means. | |
```SQL | |
CREATE TABLE thetablename(id SERIAL, | |
firstthing CHARACTER VARYING) | |
``` | |
#### Table Two | |
The table contains these features, this is what each one of them means. | |
```SQL | |
CREATE TABLE thetablename(id SERIAL, | |
firstthing CHARACTER VARYING) | |
``` | |
## Key Report Elements | |
Given the data models, these are the things we want to know, this is how we want to do it. | |
### Setting up the Database Link | |
Now we set things up. | |
```{r} | |
library(RPostgreSQL) | |
library(jsonlite) | |
dbcon <- fromJSON(txt = 'dbconnect.json', flatten = TRUE) | |
# Connect to a database: | |
con <- dbConnect(drv = "PostgreSQL", | |
user = dbcon$user, | |
password = dbcon$password, | |
host = dbcon$host, | |
port = dbcon$port, | |
dbname = dbcon$database) | |
``` | |
### Defining Each Report Element | |
Here is the first thing that we're going to look at, this is why it's important and what it all means. | |
```{r} | |
RPostgreSQL::dbGetQuery(con, | |
"SELECT values FROM table WHERE thing = 'something'") | |
``` | |
Stuff. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment