Kaggle: Intro to SQL
Notebook
- SQL, is a programming language used with databases.
- BigQuery: A web service to apply SQL to huge datasets.
- In BigQuery each dataset it contained in a corresponding project.
- To access a dataset:
Construct a reference to the dataset with thedataset()method. Here's how:dataset_ref = client.dataset("hacker_news", project="bigquery-public-data") dataset = client.get_dataset(dataset_ref) - Then we use
get_dataset()method to fetch the dataset. - Every dataset is a collection of tables. Dataset is like spreadsheets.
list_tablesmethod to list the tables in the dataset.tables = list(client.list_tables(dataset))- Print names of all tables in the dataset
for table in tables: print(table.table_id) - Fetch a table from reference:
# Construct a reference to the "full" table table_ref = dataset_ref.table("full") # API request - fetch the table table = client.get_table(table_ref) -