2tvenom / myreplication

Golang MySql binary log replication listener

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get the column name

happilymarrieddad opened this issue · 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!

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.