void fakeCloneOldTable(struct sqlConnection *oldConn, struct sqlConnection *newConn, char *table) /* Clone cart table in newConn from oldConn. Add fake prefix to * contents field to help mark it as fake. */ { char query[256]; sqlSafef(query, sizeof(query), "select * from %s", table); struct sqlResult *sr = sqlGetResult(oldConn, query); char **row; FILE *f = hgCreateTabFile(NULL, table); while ((row = sqlNextRow(sr)) != NULL) { int i; for (i=0; i<cartNumFields; ++i) { if (i != 0) fprintf(f, "\t"); if (i == 1) fprintf(f, "%s", fakePrefix); fprintf(f, "%s", row[i]); } fprintf(f, "\n"); } hgLoadTabFile(newConn, NULL, table, &f); hgUnlinkTabFile(NULL, table); }
static void loadTable(struct bed4 *beds, char *db, char *parTable) /* create and load table */ { struct sqlConnection *conn = sqlConnect(db); char sqlCmd[256]; sqlSafef(sqlCmd, sizeof(sqlCmd), createSql, parTable); sqlRemakeTable(conn, parTable, sqlCmd); FILE *tabFh = hgCreateTabFile(NULL, parTable); writeBeds(beds, tabFh); hgLoadTabFile(conn, NULL, parTable, &tabFh); hgUnlinkTabFile(NULL, parTable); sqlDisconnect(&conn); }