The second code does not have any problems, except the following error:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

which was due to parsed argument number-of-db-lines being None, so I added some default values:
parser.add_argument('-n', '--number-of-db-lines', type=int, default=60000)

and it works fine:

Getting batches
.
Finished without errors