b5cd41df4b0f7113a4641a82973ddcd331df1c1b
hiram
  Fri Feb 15 10:11:17 2019 -0800
ready to select table data refs #18869

diff --git src/hg/hubApi/apiUtils.c src/hg/hubApi/apiUtils.c
index 5b7d8b2..fc605f2 100644
--- src/hg/hubApi/apiUtils.c
+++ src/hg/hubApi/apiUtils.c
@@ -19,15 +19,31 @@
 struct jsonWrite *apiStartOutput()
 /* begin json output with standard header information for all requests */
 {
 time_t timeNow = time(NULL);
 // struct tm tm;
 // gmtime_r(&timeNow, &tm);
 struct jsonWrite *jw = jsonWriteNew();
 jsonWriteObjectStart(jw, NULL);
 jsonWriteString(jw, "apiVersion", "0.1");
 jsonWriteString(jw, "source", "UCSantaCruz");
 jsonWriteDateFromUnix(jw, "downloadTime", (long long) timeNow);
 jsonWriteNumber(jw, "downloadTimeStamp", (long long) timeNow);
 return jw;
 }
 
+void tableColumns(struct sqlConnection *conn, struct jsonWrite *jw, char *table)
+/* output the column names for the given table */
+{
+jsonWriteListStart(jw, "columnNames");
+char query[1024];
+sqlSafef(query, sizeof(query), "desc %s", table);
+struct sqlResult *sr = sqlGetResult(conn, query);
+char **row;
+row = sqlNextRow(sr);
+if (NULL == row)
+    apiErrAbort("internal error: can not 'desc' SQL table '%s'", table);
+while ((row = sqlNextRow(sr)) != NULL)
+    jsonWriteString(jw, NULL, row[0]);
+sqlFreeResult(&sr);
+jsonWriteListEnd(jw);
+}