I\'m currently using Pandas to_sql in order to place a large dataframe into an SQL database. I\'m using sqlalchemy in order to connect with the database and part of that process
The answer is indeed what you suggest: it is looking at the column names. So matching columns names is important, the order does not matter.
To be fully correct, pandas will not actually check this. What to_sql
does under the hood is executing an insert statement where the data to insert is provided as a dict, and then it is just up to the database driver to handle this.
This also means that pandas will not check the dtypes or the number of columns (e.g. if not all fields of the database are present as columns in the dataframe, these will filled with a default value in the database for these rows).