Skip to main content

Hi there,

I'm trying to read attributes from a shapefile and write them into a SQL database. I need to write also the data type for every attribute, exactly as written in shape (not based on their values). How can I extract data types from data source?

Thank you for any help!

EXPAND THIS POST FOR MY UPDATE

 

I tested with an Postgris database and get following results:

 

id = long -> Int4

firsttext = char(80) -> varchar(80)

secondtext = char(200)-> varchar(200)

number = long -> Int4

other_numb = float -> Float4

date = date -> date

 

when connecting the schema to the writer and setting everything to dynamic. Removing all attributes from the User Attributes tab in the writer.

 

 

Guess that if you need more control you need to specify the Native Attribute Translation on the Schema Feature or specify the Schema manual.

 

 

Edit:

I did some more investigation and it looks like a shape file only knows 3 data types:

 

C for Character -> CHAR(x)

N for Numeric -> NUMERIC(x,y)

D for Date -> Date

 

But the reader gives native data types like short and long for these numeric data types. So i guess you need to read the DBF to figure out the real data types?

 

To write the correct data types to your SQL database you need to use the fme_char(x), fme_decimal(x,y) and fme_date as attribute_data_type. Where x and y are numbers.

 


If you read the data using the FeatureReader transformer, you'll get the datatypes from the <Schema> output port.

You'll find some details about the output here: https://community.safe.com/s/article/dynamic-workflow-tutorial-destination-schema-is-de-2


If you read the data using the FeatureReader transformer, you'll get the datatypes from the <Schema> output port.

You'll find some details about the output here: https://community.safe.com/s/article/dynamic-workflow-tutorial-destination-schema-is-de-2

Thank you very much david_r, that's exactly what I needed!


Reply