Python SQL
Python SQL
print(columnNames)
# Example:
https://colab.research.google.com/drive/1zL3BO_-hVFO5LOT_kDCVE6l_NCZTSfdi Page 1 of 4
Python sql.ipynb - Colab 13/06/24, 3:59 PM
# 'CREATE TABLE Customer (Id INTEGER PRIMARY KEY, FirstName TEXT NOT NULL)'
def generate_sql(table_name, col_names, constraints):
col_constraints = (', '.join(col_names[i] + (' ' + constraints[i] if constraints[
return f"CREATE TABLE {table_name} ({col_constraints})"
# 'CREATE TABLE Customer (Id INTEGER PRIMARY KEY, FirstName TEXT NOT NULL)'
a = ['Id', 'FirstName']
for i in range(len(a)):
print(a[i] + ' ' + b[i])
Id
FirstName TEXT NOT NULL
https://colab.research.google.com/drive/1zL3BO_-hVFO5LOT_kDCVE6l_NCZTSfdi Page 2 of 4
Python sql.ipynb - Colab 13/06/24, 3:59 PM
def hello(a):
return f'Hello {a}, (' + 'Jess' + ')' + 'Have a great day'
hello('world')
import csv
csvReaderF = csv.DictReader(csvFile)
cols = []
for row in csvReaderF:
cols.append(row['Country'])
print(sorted(set(cols)))
import csv
https://colab.research.google.com/drive/1zL3BO_-hVFO5LOT_kDCVE6l_NCZTSfdi Page 3 of 4
Python sql.ipynb - Colab 13/06/24, 3:59 PM
https://colab.research.google.com/drive/1zL3BO_-hVFO5LOT_kDCVE6l_NCZTSfdi Page 4 of 4