I am using pandas.read_sql_query to read some data from Sql server. The data types I read are int and real in Sql server, that is 32-bit integers and 32-bit floating-point values. But in the resulting dataframe the dtypes are int64 and float64. I could convert this back to 32-bit after getting the data into the Pandas dataframe, but I am reading a large amount of data so this would give memory problems. Is there a way to keep the data from Sql server in 32-bit when reading into the dataframe?
Here is an example of the db connection:
cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
query = ("SELECT "
"MId, "
"SomeInt, "
"SomeReal "
"From dbo.Example;")
df = pd.read_sql_query(query, cnxn)