× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I don't know why I feel like someone is being scolded every time I read
replies to this list.

midrange_example.py
--------------------------------------
import click
import datetime

from dateutil.relativedelta import *

# default the beginning and end dates to last month
default_beginning_date = datetime.datetime.today() +
relativedelta(months=-1, day=1)
default_ending_date = default_beginning_date + relativedelta(months=+1,
days=-1)


@click.command()
@click.option('--acct', default=49490, help='Account number')
@click.option('--bdat', default=default_beginning_date.strftime('%Y-%m-%d'),
help='Beginning Date', type=click.DateTime())
@click.option('--edat', default=default_ending_date.strftime('%Y-%m-%d'),
help='Ending Date', type=click.DateTime())
def build_spreadsheet(acct, bdat, edat):
print(acct, bdat.strftime('%m/%d/%Y'), edat.strftime('%m/%d/%Y'))
"""
Mocked up some of your code, but here is where you'll do the
spreadsheet magic

conn = None # set connection here
cursor = conn.cursor()
sql = ('SELECT bhuact, bhubld, bhuutl,'
'rfdex, bhuuse, bhuamt,'
'bhutax '
'FROM ublhu '
'INNER JOIN urvc ON bhurvc = rvrvc AND '
'bhuact = ? AND '
'bhubld BETWEEN ? AND ? AND '
'bhurvc <> \' \' '
'ORDDER BY bhubld, bhuact, hburvc')
cursor.execute(sql, [acct, bdat, edat])

for bhuact, bhubld, bhuutl, rfdex, bhuuse, bhuamt, bhutax in
c.fetchall():
print(bhuact, bhubld, bhuutl, rfdex, bhuuse, bhuamt, bhutax)
"""


if __name__ == '__main__':
build_spreadsheet()


"""
SETUP
You'll need to have click and dateutil installed

pip install click
pip install python-dateutil

click is a package that makes argument setup really simple
dateutil is a package that makes date calculations really simple

OUTPUT
-> python midrange_example.py
(49490, '12/01/2019', '12/31/2019')

-> python midrange_example.py --help
Usage: midrange_example.py [OPTIONS]

Options:
--acct INTEGER Account number
--bdat TEXT Beginning Date
--edat TEXT Ending Date
--help Show this message and exit.

-> python midrange_example.py --acct 5150
(5150, '12/01/2019', '12/31/2019')

-> python midrange_example.py --acct 5150 --bdat 2019-11-01
(5150, '11/01/2019', '12/31/2019')
"""
--------------------------------------



On Thu, Jan 9, 2020 at 11:59 AM Bryan Dietz <bdietz400@xxxxxxxxx> wrote:

Attachment are stripped by the list software

Post inline or use http://code.midrange.com <http://code.midrange.com/>
and post the URL.

Bryan

On Jan 9, 2020, at 12:53 PM, Jim Steil <jim@xxxxxxxxxxxxxxx> wrote:

John

I just replied to the email and included the script as an attachment.

-Jim

On Thu, Jan 9, 2020 at 11:37 AM John Yeung <gallium.arsenide@xxxxxxxxx>
wrote:

On Thu, Jan 9, 2020 at 12:07 PM Jim Steil <jim@xxxxxxxxxxxxxxx> wrote:

I threw together a little example of how I'd handle the argument
parsing
using click. See the notes at the bottom of the script...

-Jim

https://click.palletsprojects.com/en/master/
https://dateutil.readthedocs.io/en/stable/

The above is the entirety of your post (sans bottom-quoting the entire
thread up to that point). It seems you forgot to include a link to
your example script.

--
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://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/opensource.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.