title: Uploading tables to server in string form?
body: <p>Long story short, someone at my job asked me convert an entire DataFrame into a single string. Never got a reason as to why I'm supposed to do that. I'd appreciate it if someone could give me an explanation as to why this is necessary.</p>
  <p>I usually upload tables to a database using something like this:</p>
  <pre><code>for variable in variables:
      for row in datafile[variable]:
          cursor.execute(f&quot;INSERT INTO {table_name} ({variable}) VALUES (?)&quot;, datafile[variable][row])
  
  connection.commit()
  print(&quot;Table committed&quot;)
  </code></pre>
  <p>But now I'm being asked to convert tables into something like this:</p>
  <pre><code>|00    |01    |       955|      1000|Good |
  |01    |02    |       800|       954|Good |
  |02    |03    |       693|       799|Good |
  |03    |04    |       642|       692|Fair |
  |04    |05    |       570|       641|Fair |
  |06    |07    |       412|       499|Poor |
  |07    |08    |       331|       411|Poor |
  |08    |09    |       210|       330|Poor |
  |09    |10    |       158|       209|Risky|
  |10    |11    |        82|       157|Risky|
  |11    |12    |        00|        81|Risky|
  </code></pre>
  <p>Where string variables are left aligned while numerical variables are right aligned. The entire thing is a single string. My question is, why is this even necessary in the first place when the first method works just fine? The above string aside from the last column was made using the following piece of code:</p>
  <pre><code>min_cut = [955, 800, 693, 642, 570, 500, 412, 331, 210, 158, 82, 0]
  max_cut = [1000, 954, 799, 692, 641, 569, 499, 411, 330, 209, 157, 81]
  
  empty_str = &quot;&quot;     
  counter   = 0
  for (min_value, max_value) in zip(min_cut, max_cut):         
      empty_str += &quot;|&quot; + f&quot;{counter}&quot;.zfill(2).ljust(5) + &quot;|&quot; + f&quot;{counter + 1}&quot;.zfill(2).ljust(5) + &quot;|&quot; + str(min_value).rjust(10) + &quot;|&quot; + str(max_value).rjust(10) + &quot;|&quot; + &quot;\n&quot;         
      counter   += 1
  </code></pre>