code: def copy_db_to_csv(dsn, path, scrub_pii=False):
      
      if "postgresql://" in dsn or "postgres://" in dsn:
          conn = psycopg2.connect(dsn=dsn)
      else:
          conn = psycopg2.connect(database=dsn, user="dallinger")
      cur = conn.cursor()
      for table in table_names:
          csv_path = os.path.join(path, "{}.csv".format(table))
          with open(csv_path, "w") as f:
              sql = "COPY {} TO STDOUT WITH CSV HEADER".format(table)
              cur.copy_expert(sql, f)
      conn.close()
      if scrub_pii:
          _scrub_participant_table(path)
docs: Copy a local database to a set of CSV files.