Well, I'm back at it. I have successfully created a python script to create a spreadsheet. I took an existing RPG pgm and created a python script to duplicate the results.
Now I'm on to step 2, which I have been working on for a few days, and can't find the solution.
I'm trying to use parameter markers passing in parms to the script.
So my call is like this
python3 actchgdt.py 49490 20190101 20190131
this basics of my code are
cursor = conn.cursor()
acct = sys.argv[1]
begdate = sys.argv[2]
enddate = sys.argv[3]
query = (conn,"select bhuact, bhubld, bhuutl, rvdes, bhuuse, bhuamt, bhutax " \
"from ublhu inner join urvc on bhurvc = rvrvc" \
"and bhuact = ? and bhubld between ? and ? " \
"and bhurvc <> ' ' " \
"order by bhubld, bhuact, bhurvc ",(acct, begdate, enddate))
cursor.execute(query)
when I execute I get errors.
Traceback (most recent call last):
File "actchgdt.py", line 21, in <module>
cursor.execute(query)
File "/QOpenSys/pkgs/lib/python3.6/site-packages/ibm_db_dbi.py", line 1386, in execute
self.messages.append(InterfaceError("execute expects the first argument [%s] to be of type String or Unicode." % operation ))
TypeError: not all arguments converted during string formatting
These are all numeric fields in my database.
I've tried different methods for using the parms, but this is the latest iteration.
Thanks
Mike
-----Original Message-----
From: Smith, Mike
Sent: Friday, December 13, 2019 2:42 PM
To: IBMi Open Source Roundtable <opensource@xxxxxxxxxxxxxxxxxx>
Subject: RE: [IBMiOSS] [EXTERNAL] Re: beginning python
Thanks Kevin
I now see the same version for both users.
I installed pip3. After installing, I tried to install a package. It suggested I upgrade from pip 9.0.1 to 19.3.1 I have successfully done this.
So that's a couple of positive steps forward.
Then I tried to install xlsxwriter.
After realizing I typed it is xlxswriter, I now have that successfully installed.
Another step forward.
One more quick question specific to python syntax.
If I have this query.
query = "select cusnum, lstnam, init, cdtlmt from qiws.qcustcdt where cdtlmt > 100"
setup a connection, cursor and then execute the cursor.
Then I have the below code to write to a .csv file.
with open('qcustcdt.csv', 'w', newline='') as file:
csvf = writer(file, quoting=QUOTE_NONNUMERIC)
for row in cur:
csvf.writerow([trim_col(col) for col in row])
how would I reference a specific field.
For example if I only wanted to write a row if lstnam = 'SMITH'
I tried if lstname = 'SMITH'
I tried if ['lstname'] = 'SMITH'
Thanks again for helping get me straightened out on the versions and pip. I really appreciate it.
Mike
-----Original Message-----
From: OpenSource <opensource-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Kevin Bucknum
Sent: Friday, December 13, 2019 2:11 PM
To: IBMi Open Source Roundtable <opensource@xxxxxxxxxxxxxxxxxx>
Subject: Re: [IBMiOSS] [EXTERNAL] Re: beginning python
Ok - so 2 things. Supermike is getting his path set so the YUM packages are first. Mike isn't. Short term you can fix mike when you log in, but you should run through the steps on the page I sent earlier to make it permanent. Run the path statement on mike, and you should get the same python3 --version output.
PATH=/QOpenSys/pkgs/bin:$PATH
As for pip3 - go into the open source package management in ACS and see if you have python3-pip installed. If not, install it. Then try again.
-----Original Message-----
From: OpenSource [mailto:opensource-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of Smith, Mike
Sent: Friday, December 13, 2019 12:56 PM
To: IBMi Open Source Roundtable <opensource@xxxxxxxxxxxxxxxxxx>
Subject: Re: [IBMiOSS] [EXTERNAL] Re: beginning python
-----Original Message-----
From: OpenSource <opensource-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Kevin Bucknum
Sent: Friday, December 13, 2019 1:49 PM
To: IBMi Open Source Roundtable <opensource@xxxxxxxxxxxxxxxxxx>
Subject: Re: [IBMiOSS] [EXTERNAL] Re: beginning python
Yea - I forgot I was in /QOpensys/pkgs/bin when I ran the commands. There has to be a path difference between supermike and mike. Lets try this.
To make sure the YUM packages are setup correctly, on either user (only have to do this once)
ls -l /QOpenSys/pkgs/bin/python*
lrwxrwxrwx 1 qsys 0 18 Oct 4 2018 /QOpenSys/pkgs/bin/python2 -> python2.7
lrwxrwxrwx 1 qsys 0 32 Oct 4 2018 /QOpenSys/pkgs/bin/python2-config -> python2.7-config
-rwxr-xr-x 1 qsys 0 178632 Jul 10 2018 /QOpenSys/pkgs/bin/python2.7
-rwxr-xr-x 1 qsys 0 1691 Jul 10 2018 /QOpenSys/pkgs/bin/python2.7-config
lrwxrwxrwx 1 qsys 0 18 Dec 5 16:04 /QOpenSys/pkgs/bin/python3 -> python3.6
lrwxrwxrwx 1 qsys 0 32 Dec 5 16:04 /QOpenSys/pkgs/bin/python3-config -> python3.6-config
-rwxr-xr-x 2 qsys 0 235122 Oct 31 12:32 /QOpenSys/pkgs/bin/python3.6
lrwxrwxrwx 1 qsys 0 34 Dec 5 16:04 /QOpenSys/pkgs/bin/python3.6-config -> python3.6m-config
-rwxr-xr-x 2 qsys 0 235122 Oct 31 12:32 /QOpenSys/pkgs/bin/python3.6m
-rwxr-xr-x 1 qsys 0 3068 Oct 31 12:34 /QOpenSys/pkgs/bin/python3.6m-config
ls -l /QOpenSys/pkgs/bin/pip*
/QOpenSys/pkgs/bin/pip* not found
on both supermike and mike
echo $PATH
supermike
/QOpenSys/pkgs/bin:/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin
Mike
/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin
I ran the 2 statements you provided under supermike, then ran a echo $PATH for both users after signing off and back on.
Thanks
MIke
-----Original Message-----
From: OpenSource [mailto:opensource-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of Jack Woehr
Sent: Friday, December 13, 2019 12:29 PM
To: IBMi Open Source Roundtable <opensource@xxxxxxxxxxxxxxxxxx>
Subject: Re: [IBMiOSS] [EXTERNAL] Re: beginning python
On Fri, Dec 13, 2019 at 11:24 AM Smith, Mike <Mike_Smith@xxxxxxxxxxxxxxxx>
wrote:
Supermike user
Python3 --version python 3.6.9
ls -l python*
python* not found
ls -l pip*
pip* not found
This isn't correct shell syntax or ls syntax.
ls doesn't go look around your environment; it just looks in the current directory or directory provided in the argument list (unless you use arguments to make it recurse, but again, that only happens descending from the current directory or one you name in the argument list).
--
Jack Woehr
Absolute Performance, Inc.
12303 Airport Way, Suite 100
Broomfield, CO 80021
NON-DISCLOSURE NOTICE: This communication including any and all attachments is for the intended recipient(s) only and may contain confidential and privileged information. If you are not the intended recipient of this communication, any disclosure, copying further distribution or use of this communication is prohibited. If you received this communication in error, please contact the sender and delete/destroy all copies of this communication immediately.
--
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:
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flists.midrange.com%2fmailman%2flistinfo%2fopensource&c=E,1,-lBdCumUbcjE5JXcugOtj88Dwm3-WVc8-vBqHO87H4jIXjHeuhMB0cWjz91o0tavduoVI618N9ly9q0N3B_CqUtCRiqfDPXSLcLjqY4l&typo=1
or email: OpenSource-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2farchive.midrange.com%2fopensource.&c=E,1,tZGepx6dDyUDqtarR4WRkquviy07rMPbKX7wI2y2VEezfkrJ2Um1feptpOR7LFQHNNeL6KxnXDsvwNEwgmy5PFPglCEdHyvnmH6EcmzPGpn6RUnCqyM3Pw,,&typo=1
Help support
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fmidrange.com&c=E,1,UWqlmSiHAwGznpI3iSh-ksRr5LzgSvwmMd33C9ZOnQql1ROPQ9J11LmqFTVKCmfzm0QgyhbqHuB7gt_64m_NxM25D4LT1FNx5pWeGDRFpp0b&typo=1 by shopping at amazon.com with our affiliate
link:
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2famazon.midrange.com&c=E,1,NF5lGKX8ZYNqAo-6NUMI7x6tMMZbkZrdLnDek0sni8C5wl-hCc16Zf7hBm4yo4nf31_OChmq3-j7bBxn-MFzJR-EoL8QTu9nL-kFu3sSlI_KXg,,&typo=1
[
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.medtronsoftware.com%2fimg%2fMedtronMinilogo.bmp&c=E,1,jM38twdUS-I2MKpGJ1NEX2YhNiUkCWonnFhDo7AFN_x2-BHnaFI-my4f203RLgP2-w-Wx0s89n2-9vZ-IO2Y-nwaRJ9ejPen7ftEspBUvgteZ2c,&typo=1] Kevin Bucknum
Senior Programmer Analyst
MEDDATA / MEDTRON
120 Innwood Drive
Covington LA 70433
Local: 985-893-2550
Toll Free: 877-893-2550
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.medtronsoftware.com&c=E,1,AmunYd3yYJfAu76UrHVD0Z3-36pl5ZQASBJ1-45rHq1YwYTRqH6BSzd2n1_afcStiZidi_xBU7QGlOXyEkl1WWkof9i9ijub-tGyzlDP&typo=1
CONFIDENTIALITY NOTICE
This document and any accompanying this email transmission contain confidential information, belonging to the sender that is legally privileged. This information is intended only for the use of the individual or entity named above. The authorized recipient of this information is prohibited from disclosing this information to any other party and is required to destroy the information after its stated need has been fulfilled. If you are not the intended recipient, or the employee of agent responsible to deliver it to the intended recipient, you are hereby notified that any disclosure, copying, distribution or action taken in reliance on the contents of these documents is STRICTLY PROHIBITED. If you have received this email in error, please notify the sender immediately to arrange for return or destruction of these documents.
--
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:
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flists.midrange.com%2fmailman%2flistinfo%2fopensource&c=E,1,U6JEyQsXsxQDnJzrsArZUhKCtlAxpMHoPQ2lLYIw4WBKBAsmK8leDUhnVvhlfcH2eGzP4R_7I_pTc29KQxt-6jrHg_ljHEOXyvYv98WUiujXxxot&typo=1
or email: OpenSource-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2farchive.midrange.com%2fopensource.&c=E,1,A_nEikVzIEoNWScmS3oqzhc-rE-PXcQM-F7G9vpC1G4EU5JOqt7dD9mrE2haTwbmutR7y41qrzSBQ2WBtV3JN4t_T6UvDVHpo0j0QR2yvwYfb5pTUW0hLr9Dx-w,&typo=1
Help support
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fmidrange.com&c=E,1,iPRN-71mna7hulk-72NaYjr4r_udeQFNK6h_iedx-JSPxB6yqmoPL2twCm-jdzSWE3-irk2ULrOzI_s6grQILTyzgLuqo7AuY70TQO6cVHWiF5PVH24i&typo=1 by shopping at amazon.com with our affiliate
link:
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2famazon.midrange.com&c=E,1,mqiwz2unmxUdhfYkXVZWKOQlL1VD-D6sLIzxOaMmjfqK7j6XZLAWTw5qbMOIbxGkFT1AP3ppHq_EDtzabhi2GGx3KnHKSEUu_EGaGbk6JBKjEjaWXv7LDvWW9w,,&typo=1
NOTICE: This message, including any attachment, is intended as a confidential and privileged communication. If you have received this message in error, or are not the named recipient(s), please immediately notify the sender and delete this message.
--
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:
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flists.midrange.com%2fmailman%2flistinfo%2fopensource&c=E,1,mCqTo8rT0geL8efCUFXMBhxmlX3YqiIiz4bdQOVWUgJ0w8MUMeoYQ_sHofmx6YMtUz4JEymXo27Oazb0uSxxGz6PhbcdrPJ7-0z6XnkST5sFKAmLPJvoi-Mv&typo=1
or email: OpenSource-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2farchive.midrange.com%2fopensource.&c=E,1,1dip6EPoGIX_7Dp4uMWvbjBV0e-PxHXQABk9eigOSxxvzQMjwl9tuZstK99Jg2U0A6DQL9hVWvS_KMJNK4LBsiK-uZI9lCkZjvvud59n3skYBCDzLL4f&typo=1
Help support
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fmidrange.com&c=E,1,6I_8k2aGxtTJvdtHIYPlj-4XWzyb8Q5coyVcYTqpuTkPLr1h4qOw7-LgdI0qU6dYd6FP9qgrxynvei8QmnKgT6urqldW0b0udXfncrx3jITVig,,&typo=1 by shopping at amazon.com with our affiliate
link:
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2famazon.midrange.com&c=E,1,hobfgx2EXdU_BXIIj7nhEcatW9q-EUUJmfsH1Zhrm9_DI0UYRjEPBRQ_fDCrGAAD63LEjBzItck0KTLeJSTCZq9Z_NfYj2wY-7wgYRz9YzuXYzdwmHH8N578Iuw,&typo=1
[
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.medtronsoftware.com%2fimg%2fMedtronMinilogo.bmp&c=E,1,daK1Kwp6P08TtlTdxGrasNxEM6iJFN5N3gUxWV2IEY1UZiAUpa34LH-D3RVaHMB5szuCbOOu69QrkAqaZy-jmla624akZLeKe-NYpK07sxj9bzY5dP72kfS5fA,,&typo=1] Kevin Bucknum
Senior Programmer Analyst
MEDDATA / MEDTRON
120 Innwood Drive
Covington LA 70433
Local: 985-893-2550
Toll Free: 877-893-2550
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.medtronsoftware.com&c=E,1,euK3OtYrYjnf8uo7Q0ZXUg0YaIjKA4UAEO0MEpV65LLaqObeLCS-QJn-fbYEXJgf2BFlkDkYJNU1RcICPlHqOLl-voKfY5z7JD8PI_Z0Gj1fcLCSLA4,&typo=1
CONFIDENTIALITY NOTICE
This document and any accompanying this email transmission contain confidential information, belonging to the sender that is legally privileged. This information is intended only for the use of the individual or entity named above. The authorized recipient of this information is prohibited from disclosing this information to any other party and is required to destroy the information after its stated need has been fulfilled. If you are not the intended recipient, or the employee of agent responsible to deliver it to the intended recipient, you are hereby notified that any disclosure, copying, distribution or action taken in reliance on the contents of these documents is STRICTLY PROHIBITED. If you have received this email in error, please notify the sender immediately to arrange for return or destruction of these documents.
--
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:
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flists.midrange.com%2fmailman%2flistinfo%2fopensource&c=E,1,1lHHjKjZtm8ift10jX8_6cAm1jMBFtnKvei9-jGpDtutZuXKU13-toQOyDJ4ezgNQkZOgi7-28HV6ssgl4B_RCyWNfs72g6oBAUpBoXDfByqDng1a3g,&typo=1
or email: OpenSource-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2farchive.midrange.com%2fopensource.&c=E,1,UnyJfJybArsB6bzPD21_VvdK5482zHNjB7mvz3kXNjhC8zul6CFeD5u99urggB_XCawbsR3yvTeaH6GnF9vXU4xAMYrGtGsjXcSrzM4Ronq7X686kbQS9x3PDD6x&typo=1
Help support
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fmidrange.com&c=E,1,H8fdlAsR0D9Hr6CIU2d1R_1hv7wPye7VOivlMtSB4wDBBV7LPQ7X17eGfzi4q6dCFRaHhrEhcAlNbxr7OWSVk8XLgfvW1Kx30i1oXPQ3oUCsH5-nHqQTnHU3kIkT&typo=1 by shopping at amazon.com with our affiliate
link:
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2famazon.midrange.com&c=E,1,LbbTnmBpoIY6R-3REoYp78WgazVFJMNvjI4E628aS0ESuzaIRnl8JaCIB3xlJgpsrgaz3t8GLR_bFX16rUn-_N-SFmvWPqmlC0ayKnivBjtHhVBP5rKywx_DLw,,&typo=1
NOTICE: This message, including any attachment, is intended as a confidential and privileged communication. If you have received this message in error, or are not the named recipient(s), please immediately notify the sender and delete this message.
As an Amazon Associate we earn from qualifying purchases.