Skip to main content
pshashipreetham
18-Opal
18-Opal
March 12, 2022
Solved

Postgres to InfluxDB Migration

  • March 12, 2022
  • 2 replies
  • 4550 views

There is a situation where DataTables Data(Which is in Postgres) needed to be Migrated to the InfluxDB, such that going forward InfluxDb Streams will be used in DataTables. So, is there any best Practices by PTC provided ?

@VladimirN @AnnaAn @paic @slangley @CarlesColl @c_lowy 

Thanks,
Shashi. 

Best answer by pshashipreetham

So,

There is no particular way @slangley  mentioned. We need to write a service that adds each row in DataTable to the Stream(Created using Influx Persistence).

Example Code:

 

for (i = 0; i < FilteredAlarmsBasedOnTank.rows.length; i++) 
{
	var row = FilteredAlarmsBasedOnTank.rows[i];
	var data = {
		Alarm: row.Alarm,
		ThingName: row.ThingName,
		Facility: Thing.Facility
	};
	values.AddRow(data);
	result.AddRow(data);
	Things["TankAlarm"].AddStreamEntry({
		timestamp: row.Date,
		source: Thing.name,
		sourceType: "Thing",
		values: values
	});
	values.RemoveAllRows();
}

 


Thanks,

2 replies

Community Manager
March 15, 2022

Hi @pshashipreetham.

 

Have you reviewed the information available in the ThingWorx Help Center?

 

Regards.

 

--Sharon

 

 

pshashipreetham
18-Opal
18-Opal
March 16, 2022

Hi @slangley ,

Gone through all the Docs present in the Thingworx help center, found nothing !

Thanks,
Shashi

pshashipreetham
18-Opal
pshashipreetham18-OpalAuthorAnswer
18-Opal
December 25, 2022

So,

There is no particular way @slangley  mentioned. We need to write a service that adds each row in DataTable to the Stream(Created using Influx Persistence).

Example Code:

 

for (i = 0; i < FilteredAlarmsBasedOnTank.rows.length; i++) 
{
	var row = FilteredAlarmsBasedOnTank.rows[i];
	var data = {
		Alarm: row.Alarm,
		ThingName: row.ThingName,
		Facility: Thing.Facility
	};
	values.AddRow(data);
	result.AddRow(data);
	Things["TankAlarm"].AddStreamEntry({
		timestamp: row.Date,
		source: Thing.name,
		sourceType: "Thing",
		values: values
	});
	values.RemoveAllRows();
}

 


Thanks,

16-Pearl
December 26, 2022

hi, please can you explain this line: 

Facility: Thing.Facility

Second question: why do you add to the stream and then remove all rows from values infotable? 

values.RemoveAllRows();