Move data from one database to another database with different tags and fields

I want to copy the data from one database to another. That should actually be easy with “select into”. However, the new database has a different structure. This means that the data should be assigned to other tasks and fields. How can I best do this? I would be grateful for every tip.

The source data looks like this:

SELECT mean("value") AS "mean_value" FROM "homeassistant"."autogen"."kWh" WHERE time > :dashboardTime: AND time < :upperDashboardTime: AND "entity_id"='netzeinspeisung_energie_ksem' GROUP BY time(:interval:) FILL(null)

And this is what the target data looks like:

SELECT mean("Netzeinspeisung Energie") AS "mean_Netzeinspeisung Energie" FROM "telegraf"."modbus"."modbus" WHERE time > :dashboardTime: AND time < :upperDashboardTime: AND "name"='KSEM' AND "host"='telegraf' AND "slave_id"='1' AND "type"='holding_register' GROUP BY time(:interval:) FILL(null)

If I can’t get any further with the “select into” command, should it possibly work with a Python script and influxdb-client?

this tells almost nothing about your data structure…

if you need to change names, you can use aliases AS. If you need to change the name of tag keys you will need a subquery as they must be listed explicitly.
If you have to change values, that’s not possible