Skip to content

Commit

Permalink
Add host command line parameter in load_demo.py, use the same command… (
Browse files Browse the repository at this point in the history
stanford-futuredata#229)

* Add host command line parameter in load_demo.py, use the same command line for load_demo2.py

* Change default password to postgres
  • Loading branch information
rockie-yang authored and kexinrong committed Dec 8, 2017
1 parent 8c02554 commit db6f165
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
9 changes: 6 additions & 3 deletions tools/load_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
if(len(sys.argv) > 1):
port = sys.argv[1]

port = None
user = None
password = None
if(len(sys.argv) > 2):
port = sys.argv[1]
user = sys.argv[2]
password = sys.argv[3]

conn = psycopg2.connect("dbname='postgres' host='localhost'" +
host = "localhost"
if (len(sys.argv) > 3):
host = sys.argv[4]

conn = psycopg2.connect("dbname='postgres'" +
(" host='" + host + "'") +
(" port="+port if port else "") +
(" user="+user if user else "") +
(" password="+password if password else ""))
Expand Down
18 changes: 17 additions & 1 deletion tools/load_demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
if(len(sys.argv) > 2):
port = sys.argv[2]

user = "postgres"
password = "postgres"
if(len(sys.argv) > 3):
user = sys.argv[3]
password = sys.argv[4]

host = "localhost"
if (len(sys.argv) > 4):
host = sys.argv[5]


# TODO: These can be made configurable later
NUM_ATTRIBUTES = 4
NUM_METRICS = 5
Expand All @@ -24,7 +35,12 @@
["CA", "MA", "NY", "WY", "AR", "NV", "PA", "WA", "WI"]
]

conn = psycopg2.connect("dbname='postgres' host='localhost'" + " port="+port if port else "" + " user=postgres password=mamikonyan")
conn = psycopg2.connect("dbname='postgres'" +
(" host='" + host + "'") +
(" port="+port if port else "") +
(" user="+user if user else "") +
(" password="+password if password else ""))

cur = conn.cursor()

print "Creating table..."
Expand Down

0 comments on commit db6f165

Please sign in to comment.