Changeset 3852 for TI01-discovery


Ignore:
Timestamp:
07/05/08 10:16:54 (11 years ago)
Author:
cbyrom
Message:

Add port to db_connect and adjust set up of connection to allow this to
be specified (connection string doesn't seem to allow the inclusion of this).
Also, remove default connection settings, to avoid security issues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI01-discovery/branches/ingestAutomation-upgrade/OAIBatch/db_funcs.py

    r3844 r3852  
    55import pgdb, logging, sys 
    66 
    7 def db_connect(databaseName='discoverydb', hostName='localhost', userName='postgres', password='pass01word'): 
     7def db_connect(databaseName, hostName, userName, password, port='5432'): 
    88        ''' 
    99        Open a Postgres database connection 
     
    1212        @param userName: Name of user to connect to DB as 
    1313        @param password: Password for user  
     14        @param port: Port to use - defaults to 5432 
    1415        ''' 
    1516        logging.info("Setting up connection to DB: " + databaseName + " on " + hostName) 
    16         connection_string = hostName + ':' + databaseName + ':' + userName + ':' + password 
    17         connection = pgdb.connect(connection_string) 
     17        connection = pgdb.connect(host = hostName + ":" + port, database= databaseName, \ 
     18                                                          user = userName, password = password) 
    1819        logging.info("DB connection established") 
    1920        return connection 
Note: See TracChangeset for help on using the changeset viewer.