I am using GeoPandas from_postgis function to read data from PostGIS. However, the data types of the GeoPandas columns are always object.
Data I store in PostGIS is mixture of text/char, bool, integer and geom (snip below).
I have no issue with geom and text but integer and bool data is not maintained over the process.
Python script I created reads 4 layers from the database, clip it within a polygon and export it as a geopackage.
conn_string = f'postgresql://postgres:abcs@15612:5432/wi_designsdb' #database string
db = create_engine(conn_string) #create engine from the string above
conn = db.connect() #connect to database
df= gpd.GeoDataFrame.from_postgis(f'select * from pia.pole',con=conn, geom_col='geometry')
df = df.clip(build_project)
df = df[columns_list]
df.to_file(merginmaps_output_folder + 'pole.gpkg')
Data types in DB:
Data types in GeoDataFrame:
Data types in QGIS: