How to specify data types: add "from sqlalchemy.types import String, SmallInteger" replacing String and SmallInteger with the types you need. Then, do "df.to_sql('people', con=engine, if_exists='replace', index=False, dtype={'First Name': String(length=255), 'Last Name': String(length=255), 'Age': SmallInteger, 'Phone Number': String(length=255)})" Sorry for not including this in the video, I didn't think it would be a super common need.
please help, my database is linked with PKs and FKs, I modified the table with a new attribute, how can I append the new data from a excel file to that specific column
SQLAlchemy supports various drivers to connect to MS SQL such as PyODBC which you can find details to on connection strings here: docs.sqlalchemy.org/en/13/dialects/mssql.html#module-sqlalchemy.dialects.mssql.pyodbc Note that if you have a pre-configured ODBC source on the client you can use the shorter DSN syntax otherwise you need to use a longer hostname connection string.
When trying this i unfortunate keep getting an error saying "ModuleNotFoundError: No module named 'MySQLdb' ", do you have any ideas on why and even maybe a solution.
It's not MySQL that's the issue, it's that python is missing the library it needs to connect to MySQL (MySQLdb). Try these instructions to get it installed: www.radishlogic.com/coding/python-3/installing-mysqldb-for-python-3-in-windows/ Note that I have not tested these instructions.
What's the desired behaviour here? My recommendation would be to try because I don't think I've ever done that, it would probably create an empty table. But if you just want it to create a table, just create the table using SQL like you normally would. If you want it to do nothing, make sure you're on append mode and it shouldn't do anything.
Please see the pinned comment for the data types. If you wish, specify index=True and the pandas indexes will be carried over to SQL. You can use regular methods to manipulate the pandas indexes, although that may require a look at pandas documentation and further familiarizing yourself with the library if you you are not already.