title: Trying to load a pandas df into an already created table in a SQL server database. I am able to connect and create a new table but unable to load df
body: <p>Trying to load a pandas df into an already created table in a SQL server database. I am able to connect and create a new table but unable to load a df
  My code is here:</p>
  <pre><code># Dependencies
  from sqlalchemy import create_engine
  import urllib
  
  # Variables
  server = 'My_Server\SQLEXPRESS'
  database = 'My_db'
  
  # Connect to sql db
  conn_str = (
      r'Driver=ODBC Driver 17 for SQL Server;'
      r'Server=My_Server\SQLEXPRESS;'
      r'Database=My_db;'
      r'Trusted_Connection=yes;'
  )
  quoted_conn_str = urllib.parse.quote_plus(conn_str)
  engine = create_engine(f'mssql+pyodbc:///?odbc_connect={quoted_conn_str}')
  
  cnxn = engine.connect()
  
  # Load df to sql db 
  My_df.to_sql(name = 'myTable1', con = cnxn, if_exists = 'append',index = False)
  cnxn.close()
  </code></pre>
  <p>Here's the error I get:
  ProgrammingError: (pyodbc.ProgrammingError) ('42000', &quot;[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]String or binary data would be truncated in table 'representation_v1.dbo.RepresentationTable1', column 'Country'. Truncated value: '\xa0'. (2628) (SQLExecDirectW); [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The statement has been terminated. (3621)&quot;)
  [SQL: INSERT INTO [RepresentationTable1] ([Country], [countryCode], [Population], [LHR], [UHR], [CPRLH], [CPRUH], [Groups]) VALUES (?, ?, ?, ?, ?, ?, ?, ?)].......</p>
  <p><a href="https://i.stack.imgur.com/VLR4j.png" rel="nofollow noreferrer">enter image description here</a></p>