The first parameter is a DSN string. You must either use:
    
   db2.connect('DATABASE=*LOCAL;UID=username;PWD=password')
    
   or use the database keyword argument and leave the dsn (first) argument as
   None (default):
    
   db2.connect(database=database, username=username, password=password)
    
    
     ----- Original message -----
     From: Mike Loyd <mloyd@xxxxxxx>
     Sent by: "OpenSource" <opensource-bounces@xxxxxxxxxxxxxxxxxx>
     To: IBMi Open Source Roundtable <opensource@xxxxxxxxxxxxxxxxxx>
     Cc:
     Subject: [EXTERNAL] Re: [IBMiOSS] CSV file in the IFS, writing it to a
     DB2 file using Python
     Date: Thu, Jun 27, 2019 1:08 PM
      
     Hi
     Here is the traceback -
     Traceback (most recent call last):
       File "read2_csv.py", line 11, in <module>
         conn = db2.connect(database,user,password)
       File "/QOpenSys/pkgs/lib/python3.6/site-packages/ibm_db_dbi.py", line
     667, in connect
         return _connect_helper(ibm_db.connect, dsn, user, password, host,
     database, conn_options)
       File "/QOpenSys/pkgs/lib/python3.6/site-packages/ibm_db_dbi.py", line
     578, in _connect_helper
         options = dict( (k.strip().upper(), v.strip()) for k, v in tokens )
       File "/QOpenSys/pkgs/lib/python3.6/site-packages/ibm_db_dbi.py", line
     578, in <genexpr>
         options = dict( (k.strip().upper(), v.strip()) for k, v in tokens )
     ValueError: not enough values to unpack (expected 2, got 1)
     Line 11 is conn = db2.connect(database,user,password)
     In my other script I connect using the default,  conn = db2.connect()
     I need to use the user and password parms to connect when the script is
     used in production.
     -----Original Message-----
     From: OpenSource [[1]mailto:opensource-bounces@xxxxxxxxxxxxxxxxxx] On
     Behalf Of John Yeung
     Sent: Thursday, June 27, 2019 10:01 AM
     To: IBMi Open Source Roundtable <opensource@xxxxxxxxxxxxxxxxxx>
     Subject: Re: [IBMiOSS] CSV file in the IFS, writing it to a DB2 file
     using Python
     On Thu, Jun 27, 2019 at 12:45 PM Mike Loyd <mloyd@xxxxxxx> wrote:
     >
     > Hi there
     > I am trying to connect to DB2  in python using the following -
     >
     > import ibm_db_dbi as db2
     > sys_nam = "*LOCAL"
     > user = "USER"
     > password = "PASSWORD"
     > conn = db2.connect(sys_nam,user,password)
     >
     > I am receiving this error when running the script -
     > ValueError: not enough values to unpack (expected 2, got 1)
     It's helpful if you give more information than that. Ideally, you should
     provide the entire traceback, but if that's really long, you should at
     least give the last few lines. Crucially, they will reveal which exact
     line of code triggered the error.
     As it stands, I don't see any code that could have produced the error
     that you're reporting.
     Also, earlier you said you already have a script which gets data from an
     Excel workbook into the database. How is *that* script connecting to the
     database?
     John Y.
     --
     This is the IBMi Open Source Roundtable (OpenSource) mailing list To
     post a message email: OpenSource@xxxxxxxxxxxxxxxxxx To subscribe,
     unsubscribe, or change list options,
     visit: [2]
https://lists.midrange.com/mailman/listinfo/opensource
     or email: OpenSource-request@xxxxxxxxxxxxxxxxxx
     Before posting, please take a moment to review the archives at
     [3]
https://archive.midrange.com/opensource ;.
     Help support midrange.com by shopping at amazon.com with our affiliate
     link: [4]
https://amazon.midrange.com ;
     --
     This is the IBMi Open Source Roundtable (OpenSource) mailing list
     To post a message email: OpenSource@xxxxxxxxxxxxxxxxxx
     To subscribe, unsubscribe, or change list options,
     visit: [5]
https://lists.midrange.com/mailman/listinfo/opensource ;
     or email: OpenSource-request@xxxxxxxxxxxxxxxxxx
     Before posting, please take a moment to review the archives
     at [6]
https://archive.midrange.com/opensource ;.
     Help support midrange.com by shopping at amazon.com with our affiliate
     link: [7]
https://amazon.midrange.com ;
      
    
References
   Visible links
   1. mailto:opensource-bounces@xxxxxxxxxxxxxxxxxx
   2. 
https://lists.midrange.com/mailman/listinfo/opensource
   3. 
https://archive.midrange.com/opensource
   4. 
https://amazon.midrange.com/
   5. 
https://lists.midrange.com/mailman/listinfo/opensource
   6. 
https://archive.midrange.com/opensource
   7. 
https://amazon.midrange.com/
As an Amazon Associate we earn from qualifying purchases.