~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/database/sqlbase.py

  • Committer: William Grant
  • Date: 2011-09-06 04:36:09 UTC
  • mto: (7675.1045.785 db-devel)
  • mto: This revision was merged to the branch mainline in revision 13935.
  • Revision ID: william.grant@canonical.com-20110906043609-d475161ngtfqc4mu
The user argument to connect_string and connect is now optional.

Show diffs side-by-side

added added

removed removed

Lines of Context:
781
781
    transaction.commit()
782
782
 
783
783
 
784
 
def connect(user, dbname=None, isolation=ISOLATION_LEVEL_DEFAULT):
 
784
def connect(user=None, dbname=None, isolation=ISOLATION_LEVEL_DEFAULT):
785
785
    """Return a fresh DB-API connection to the MAIN MASTER database.
786
786
 
787
 
    DEPRECATED - if needed, this should become a method on the Store.
788
 
 
789
 
    Use None for the user to connect as the default PostgreSQL user.
790
 
    This is not the default because the option should be rarely used.
 
787
    Can be used without first setting up the Component Architecture,
 
788
    unlike the usual stores.
791
789
 
792
790
    Default database name is the one specified in the main configuration file.
793
791
    """
794
 
    con = psycopg2.connect(connect_string(user, dbname))
 
792
    con = psycopg2.connect(connect_string(user=user, dbname=dbname))
795
793
    con.set_isolation_level(isolation)
796
794
    return con
797
795
 
798
796
 
799
 
def connect_string(user, dbname=None):
 
797
def connect_string(user=None, dbname=None):
800
798
    """Return a PostgreSQL connection string.
801
799
 
802
800
    Allows you to pass the generated connection details to external