Pandas version checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this bug exists on the latest version of pandas.

  • [X] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

### Push this to Postgresql ###
create table product(
product_id varchar(255) primary key not null,
price varchar(255) not null,
gender varchar(255),
name varchar(255) not null,
recommendable boolean not null,
is_active boolean  not null,
fk_event_number integer references event(event_number) not null
);

### call pandas function ###

df_products_db = pd.read_sql_table("product",engine.connect())

print(df_products_db.dtypes) # returns 4 object data types, should be strings

Issue Description

When using pandas.read_sql_table() to request data from a (in my case) localhost postgres database, the data types returned are different then the data types specified in the postgresql enviorment

Expected Behavior

Data types should be strings (as they are varchar(255) in the database), but return as object types

Installed Versions

INSTALLED VERSIONS ------------------ commit : 2e218d10984e9919f0296931d92ea851c6a6faf5 python : 3.10.6.final.0 python-bits : 64 OS : Linux OS-release : 5.19.0-35-generic Version : #36~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Feb 17 15:17:25 UTC 2 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 1.5.3 numpy : 1.24.1 pytz : 2022.1 dateutil : 2.8.1 setuptools : 59.6.0 pip : 22.0.2 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : 4.8.0 html5lib : 1.1 pymysql : None psycopg2 : 2.9.5 jinja2 : 3.1.2 IPython : None pandas_datareader: None bs4 : 4.10.0 bottleneck : None brotli : None fastparquet : None fsspec : None gcsfs : None matplotlib : 3.6.3 numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None pyxlsb : None s3fs : None scipy : None snappy : None sqlalchemy : 2.0.6 tables : None tabulate : None xarray : None xlrd : None xlwt : None zstandard : None tzdata : None

Comment From: asishm

object is the default data type for strings, so this is expected until the default changes.

Comment From: Alper2022

Where could i change this default?

Comment From: phofl

You can use convert_dtypes or set the dtype_backend option starting with pandas 2.0