Skip to main content
pshashipreetham
19-Tanzanite
March 12, 2022
Solved

Postgres to InfluxDB Migration

  • March 12, 2022
  • 12 replies
  • 4619 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,

12 replies

Support
March 15, 2022

Hi @pshashipreetham.

 

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

 

Regards.

 

--Sharon

 

 

pshashipreetham
19-Tanzanite
March 16, 2022

Hi @slangley ,

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

Thanks,
Shashi

Shashi Preetham || +91 8099838801 || shashi@psptechhub.com
pshashipreetham
pshashipreetham19-TanzaniteAuthorAnswer
19-Tanzanite
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,

Shashi Preetham || +91 8099838801 || shashi@psptechhub.com
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();