Skip to content

Instantly share code, notes, and snippets.

@SimonGoring
Last active September 18, 2018 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SimonGoring/d46b3f4aa56184d01b7bf25066bcf349 to your computer and use it in GitHub Desktop.
Save SimonGoring/d46b3f4aa56184d01b7bf25066bcf349 to your computer and use it in GitHub Desktop.
IPython Notebook for BAIT Group Project
{
"host": "localhost",
"port": 5432,
"database": "yourdatabase",
"user": "postgres",
"password": "postgres"
}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
---
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