Posted By

GabrielTheodoulos on 07/20/16


Tagged

table SQLite


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BigD3m0n


Create a Table sqlite3


 / Published in: Python
 

URL: https://www.youtube.com/watch?v=o-vsdfCBpsU

sqlite is a lite version of sql.

  1. import sqlite3
  2.  
  3. conn = sqlite3.connect('tutorial.db')
  4. c = conn.cursor() # think of it like a mouse cursor
  5.  
  6. def create_table():
  7. c.execute("CREATE TABLE example(Language VARCHAR, Version REAL, Skill TEXT)")
  8. # created a table called 'example' inside the db 'tutorial.db'
  9. # People will use ALL CAPS for SQL specific stuff, and lower case for everything else.
  10. #
  11. # Column 1 - 'Language' data type: VARCHAR (variable character, much like all encompassing field)
  12. # Column 2 - 'Version' data type: REAL (real numbers, much like integers)
  13. # Column 3 - 'Skill' data type: TEXT
  14.  
  15. create_table() # This is where we tell the program to run the function create_table().
  16.  
  17. conn.close() # Always be tidy by closing the file.

Report this snippet  

You need to login to post a comment.