title: Python+sqlAlchemy: change dtype object to string dynamically
body: <p>In short: I want to convert object to string dynamically for all my object columns in all my Pandas dataframes. I saw similar posts about a single conversion, but none of them deals with a dynamic conversion to strings.</p>
  
  <p>I'm writing multiple JSON files to our SQL Server database, using Python 3.x. When I import the JSON files, and store it in a Pandas DF, all strings are stored as an object, since the length is unknown in advance. Hence, when I write the data to the SQL Server, the datatype is chosen to be <code>text</code> rather than <code>varchar(255)</code></p>
  
  <p>Is there a way to dynamically convert all columns with dtype <code>object</code> to dtype <code>string</code>? The strings may be cut at the first 255 characters.</p>
  
  <p>I tried the following, but made Python crash...</p>
  
  <pre><code>url = 'some-url-to-json-file'
  params['connectionString'] = 'driver://user:pw@server/database'
  engine = sqlalchemy.create_engine(connectionString)
  response = requests.get(url)
  pandasDF = pandas.DataFrame(response.json()['value'])
  
  # Convert Objects to Strings
  for cName in list(pandasDF.columns.values):
      if pandasDF[cName].dtype == 'object':
          pandasDF[cName] = pandasDF[cName].to_string
  pandasDF.to_sql(tableName, engine, if_exists = 'append')
  </code></pre>