Skip to main content
Mar 12, 2022 8:07 AM UTC
Solved

Postgres to InfluxDB Migration

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. 

Dec 25, 2022 10:58 AM UTC

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,

12 replies

Mar 15, 2022 6:49 PM UTC

Hi @pshashipreetham.

 

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

 

Regards.

 

--Sharon

 

 

Mar 16, 2022 1:51 AM UTC

Hi @slangley ,

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

Thanks,
Shashi

pshashipreethamAuthorAnswer
Dec 25, 2022 10:58 AM UTC

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,

Dec 26, 2022 5:08 PM UTC

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();