Question

Copy only Schema to an other database


Badge +10

Hello

Is there a way we could copy only the schema ( table name and related attribute ) no data into another database, SQL server, and Postgres, multiple table at once

Thanks


11 replies

Badge +2

Hi,

I have not tested but try by passing one feature with feature writer and truncate the table after feature writer.

This just a workaround.

Pratap

Badge +10

yes it is , but some tables are empty from the source

Userlevel 4

It's possible, but a bit convoluted. FME isn't schema based, it's feature based. This means that if there's no feature arriving at the output feature type, then nothing happens: no table creation, truncates, etc.

As @pratap suggests, it's possible to work around this by creating and writing dummy features which you delete in the end, e.g. using a shutdown SQL script or a second workspace.

Badge +2

yes it is , but some tables are empty from the source

Have you tied Schema (Any Format) reader?
Userlevel 4
Have you tied Schema (Any Format) reader?
Unfortunately you cannot write schemas, only read them...
Badge +10

It's possible, but a bit convoluted. FME isn't schema based, it's feature based. This means that if there's no feature arriving at the output feature type, then nothing happens: no table creation, truncates, etc.

As @pratap suggests, it's possible to work around this by creating and writing dummy features which you delete in the end, e.g. using a shutdown SQL script or a second workspace.

@david_r

 

is ok for the table with features about the empty table how could add a fake feature if we cant read them, and we don't know those table in advance since we are reading Dynamic schema, and there is many tables there

 

 

Badge +2
Unfortunately you cannot write schemas, only read them...
Yes, but objective at this moment is to generate a feature and not writing :)

 

Userlevel 4
@david_r

 

is ok for the table with features about the empty table how could add a fake feature if we cant read them, and we don't know those table in advance since we are reading Dynamic schema, and there is many tables there

 

 

Have a look at the NoFeaturesTester from the FME Hub, it may be helpful here.

 

For reading the schemas, I would recommend using the FeatureReader, which will enable you to read both the schema and the features in one go (no need to use the separate schema reader).
Badge +2
Have a look at the NoFeaturesTester from the FME Hub, it may be helpful here.

 

For reading the schemas, I would recommend using the FeatureReader, which will enable you to read both the schema and the features in one go (no need to use the separate schema reader).
Yes this transformer will work for sure...

 

 

Badge +10

It's possible, but a bit convoluted. FME isn't schema based, it's feature based. This means that if there's no feature arriving at the output feature type, then nothing happens: no table creation, truncates, etc.

As @pratap suggests, it's possible to work around this by creating and writing dummy features which you delete in the end, e.g. using a shutdown SQL script or a second workspace.

if we use a dynamic reader to read multiple tables it will give you only table with feature and ignore the one without

 

the other option I tested is to use feature reader, but use the schema output then use list exploder to expose all the attributes not we are getting in one column the name of the table and the second one the name of the attribute , but how we could now pass that to the database in order to create the those table.

 

feature-reader-output.png

 

schema-extraction.png

 

 

 

 

Badge +2
if we use a dynamic reader to read multiple tables it will give you only table with feature and ignore the one without

 

the other option I tested is to use feature reader, but use the schema output then use list exploder to expose all the attributes not we are getting in one column the name of the table and the second one the name of the attribute , but how we could now pass that to the database in order to create the those table.

 

feature-reader-output.png

 

schema-extraction.png

 

 

 

 

It seems, you are using schema reader instead of reading empty table

 

 

Reply