fixed 'lost connection to underlying DBMS' issue in loadShapefile() by including a try-except that manually reconnects to the database using cursorContext()