Skip to content

Commit 9d0232d

Browse files
committed
Changed to use .yml file
1 parent f706317 commit 9d0232d

6 files changed

Lines changed: 22 additions & 15 deletions

File tree

.DS_Store

6 KB
Binary file not shown.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This script allows users to download a CSV of raw SQL from queries in a report.
55
# Steps to use this script:
66

77
1. In Mode, generate API token (under Settings -> Your Name -> API Tokens).
8-
2. Add the token and password values to the python.properties file.
8+
2. Add the token and password values to the mode.yml file.
99
3. Run this script using:
1010
`python demo.py -org={{organization_username}} -reporttoken={{report_token}}`
1111

demo.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

2-
import json, requests, datetime, ConfigParser, argparse, sys, csv
2+
import json, requests, datetime, ConfigParser, argparse, sys, csv, yaml
33
from requests.auth import HTTPBasicAuth
44

55

66
def get_auth(whichAuth):
7-
file = 'python.properties'
8-
config = ConfigParser.RawConfigParser()
9-
config.read(file)
10-
token = config.get('ModeSection', 'token')
11-
password = config.get('ModeSection', 'password')
7+
with open ('mode.yml', 'r') as f:
8+
mode = yaml.load(f)
9+
10+
token = mode["mode"]["token"]
11+
password = mode["mode"]["password"]
1212
auth = (token, password)
1313
return auth
1414

mode.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mode:
2+
token:
3+
password:

python.properties

Lines changed: 0 additions & 8 deletions
This file was deleted.

sql.csv

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Query Token,SQL Query
2+
d832cd041c7a,"SELECT
3+
*
4+
FROM
5+
benn.nfl_touchdowns "
6+
790de3c8b5ad,"SELECT
7+
team,
8+
COUNT(touchdown_id) AS total_touchdowns
9+
FROM
10+
benn.nfl_touchdowns
11+
GROUP BY 1
12+
ORDER BY 2 DESC"

0 commit comments

Comments
 (0)