title: how to create a SQL database from a csv file in Python
body: <p>I need to load in a large dataset (20gb for now but will be 100 gb in the future) from a csv file. I am using the MySQLdb module in python (PyCharm). I also need to only select some certain columns. So far I have tried this:</p>
  
  <pre><code>import csv
  import MySQLdb
  
  mydb = MySQLdb.connect(host='localhost',
      user='root',
      passwd='',
      db='mydb')
  cursor = mydb.cursor()
  
  csv_data = csv.reader(file('collected_quotes_sample.csv'))
  for row in csv_data:
      cursor.execute('INSERT INTO testcsv(RIC, Date, Time, Ask, Bid, BAS, window ) VALUES(%s, %s, %s, %s, %s, %s, %s)', row)
  #close the connection to the database.
  mydb.commit()
  cursor.close()
  print "Done"
  </code></pre>
  
  <p>but it provides many errors. I am new to python and SQL database so I am not familiar with the commands/codes. So I have a few questions:</p>
  
  <pre><code>1. with MySQLdb.connect( host,user,passwd,db etc), what are host, user, password etc? to my understanding, they are credentials for my account in the computer. so do I need to put in my user account and password?
  2. What does mydb.cursor do?
  3. How to upload a csv file into a SQL database? and after the database is created, I can write a python script to work on it and there is no need to re read/create the database?
  </code></pre>
  
  <p>Thanks a lots!</p>