myreplication icon indicating copy to clipboard operation
myreplication copied to clipboard

Get the column name

Open happilymarrieddad opened this issue 5 years ago • 1 comments

Is there a way to get the name of the column when you are reading from an event. I've looked through the code and I can't seem to find a good way to do this. Getting the values and the tableId are useful but not if I don't know what the column name for that table is. Here is an example

case *myreplication.WriteEvent:
				Output Write (insert) event
				println("Write", e.GetTable())
				println("NewID", e.GetTableId())
				spew.Dump(e)
				//Rows loop
				for _, row := range e.GetRows() {
					//Columns loop
					fmt.Println("")
					fmt.Println("Row")
					spew.Dump(row)
					fmt.Println("End Row")
					for _, col := range row {
						fmt.Println("Col")
						spew.Dump(col)
						
                                               // HERE IT WOULD BE NICE IF I COULD KNOW THE COLUMN NAME 
                                               
                                               // fmt.Println(col.GetColumnName())
						fmt.Println("EndCol")
						fmt.Println("")
						//Output row number, column number, column type and column value
						//println(fmt.Sprintf("%d %d %d %v", i, j, col.GetType(), col.GetValue()))
					}
				}

Or if there is a way to read the event into a table struct? Thanks!

happilymarrieddad avatar Oct 04 '18 20:10 happilymarrieddad

Basically, I want to be able to pass this data to a client listening on the socket but I can't seem to read the data into an object.

happilymarrieddad avatar Oct 04 '18 20:10 happilymarrieddad