Skip to content

Commit

Permalink
Support for accessing remote DBs.
Browse files Browse the repository at this point in the history
  • Loading branch information
orviz committed Feb 2, 2016
1 parent 60f6f84 commit 0b5d323
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions identities/identifier2sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
from optparse import OptionParser
import logging, MySQLdb, sys, random

def open_database(myuser, mypassword, mydb):
con = MySQLdb.Connect(host="127.0.0.1",
def open_database(myuser, mypassword, mydb, myhost):
con = MySQLdb.Connect(host=myhost,
port=3306,
user=myuser,
passwd=mypassword,
Expand Down Expand Up @@ -57,6 +57,11 @@ def read_options():
dest="dbpassword",
default="",
help="Database password")
parser.add_option("--db-host",
action="store",
dest="dbhost",
default="127.0.0.1",
help="Database host")
parser.add_option("-g", "--debug",
action="store_true",
dest="debug",
Expand Down Expand Up @@ -147,7 +152,7 @@ def check_uidentities_table(cursor, con):
if username != 'y':
sys.exit(0)

con = open_database(opts.dbuser, opts.dbpassword, opts.dbname)
con = open_database(opts.dbuser, opts.dbpassword, opts.dbname, opts.dbhost)
cursor = con.cursor()
check_uidentities_table(cursor, con)
q = "SELECT uuid FROM uidentities "
Expand Down

0 comments on commit 0b5d323

Please sign in to comment.