docs: def fetch_from_pgdb(self, tables, cxn, limit=None, force=False):
          """
          Will fetch all Postgres tables from the specified database
              in the cxn connection parameters.
          This will save them to a local file named the same as the table,
              in tab-delimited format, including a header.
          :param tables: Names of tables to fetch
          :param cxn: database connection details
          :param limit: A max row count to fetch for each table
          :return: None
          """
  
          con = None
          try:
              con = psycopg2.connect(
                  host=cxn['host'], database=cxn['database'], port=cxn['port'],
                  user=cxn['user'], password=cxn['password'])
              cur = con.cursor()
              for tab in tables:
                  LOG.info("Fetching data from table %s", tab)
                  self._getcols(cur, tab)
                  query = ' '.join(("SELECT * FROM", tab))
                  countquery = ' '.join(("SELECT COUNT(*) FROM", tab))
                  if limit is not None:
                      query = ' '.join((query, "LIMIT", str(limit)))
                      countquery = ' '.join((countquery, "LIMIT", str(limit)))
  
                  outfile = '/'.join((self.rawdir, tab))
  
                  filerowcount = -1
                  tablerowcount = -1
                  if not force:
                      # check local copy.  assume that if the # rows are the same,
                      # that the table is the same
                      # TODO may want to fix this assumption
                      if os.path.exists(outfile):
                          # get rows in the file
                          filerowcount = self.file_len(outfile)
                          LOG.info(
                              "(%s) rows in local file for table %s", filerowcount, tab)
  
                      # get rows in the table
                      # tablerowcount=cur.rowcount
                      cur.execute(countquery)
                      tablerowcount = cur.fetchone()[0]
  
                  # rowcount-1 because there's a header
                  if force or filerowcount < 0 or (filerowcount-1) != tablerowcount:
                      if force:
                          LOG.info("Forcing download of %s", tab)
                      else:
                          LOG.info(
                              "%s local (%d) different from remote (%d); fetching.",
                              tab, filerowcount, tablerowcount)
                      # download the file
                      LOG.info("COMMAND:%s", query)
                      outputquery = """
      COPY ({0}) TO STDOUT WITH DELIMITER AS '\t' CSV HEADER""".format(query)
                      with open(outfile, 'w') as f:
                          cur.copy_expert(outputquery, f)
                  else:
                      LOG.info("local data same as remote; reusing.")
  
          finally:
              if con:
                  con.close()
          return