Skip to main content
Question

Copy only Schema to an other database


boubcher
Contributor
Forum|alt.badge.img+11

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

pratap
Contributor
Forum|alt.badge.img+11
  • Contributor
  • July 6, 2018

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


boubcher
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • July 6, 2018

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


david_r
Celebrity
  • July 6, 2018

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.


pratap
Contributor
Forum|alt.badge.img+11
  • Contributor
  • July 6, 2018
boubcher wrote:

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

Have you tied Schema (Any Format) reader?

david_r
Celebrity
  • July 6, 2018
pratap wrote:
Have you tied Schema (Any Format) reader?
Unfortunately you cannot write schemas, only read them...

boubcher
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • July 6, 2018
david_r wrote:

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

 

 


pratap
Contributor
Forum|alt.badge.img+11
  • Contributor
  • July 6, 2018
david_r wrote:
Unfortunately you cannot write schemas, only read them...
Yes, but objective at this moment is to generate a feature and not writing :)

 


david_r
Celebrity
  • July 6, 2018
boubcher wrote:
@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).

pratap
Contributor
Forum|alt.badge.img+11
  • Contributor
  • July 6, 2018
david_r wrote:
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...

 

 


boubcher
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • July 6, 2018
david_r wrote:

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

 

 

 

 


pratap
Contributor
Forum|alt.badge.img+11
  • Contributor
  • July 6, 2018
boubcher wrote:
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

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings