import pandas as pd
from sqlalchemy import create_engine
# read in the Statal file
df = pd.read_stata('1.dta')
# create a connection to the MySQL database
engine = create_engine('mysql://user:password@host:port/database')
# write the data to a table in the MySQL database
df.to_sql('table_name', con=engine, if_exists='replace')
import pandas as pd
from sqlalchemy import create_engine
# read in the Statal file
df = pd.read_stata('1.dta')
print(df.dtypes)
print(df.columns)
df=df.convert_dtypes() # 智能数据类型选择 object 转string
liex=list(df.dtypes)
liem=list(df.columns)
for a,b in zip(liex,liem):
print(a,b)