summaryrefslogtreecommitdiff
path: root/plac/doc/example4.py
blob: 2e76b65bc9e7cd923f3e95c8eaa696874de71bc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# example4.py
from datetime import datetime

def main(dsn, table='product', today=datetime.today()):
    "Do something on the database"
    print(dsn, table, today)

if __name__ == '__main__':
    import sys
    args = sys.argv[1:]
    if not args:
        sys.exit('usage: python %s dsn' % sys.argv[0])
    elif len(args) > 2:
        sys.exit('Unrecognized arguments: %s' % ' '.join(argv[2:]))
    main(*args)