forked from MarkBroeksteeg/open-data-api
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_database.py
More file actions
30 lines (26 loc) · 858 Bytes
/
create_database.py
File metadata and controls
30 lines (26 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import sqlite3
# This file creates a new SQLite database with the desired column names.
def create_database_and_table(db_name):
# Connect to the SQLite database. It will be created if it does not exist.
conn = sqlite3.connect(db_name)
cursor = conn.cursor()
# Create a table with the new column names
cursor.execute('''
CREATE TABLE IF NOT EXISTS EmploymentData (
ID TEXT PRIMARY KEY,
GeoUnit TEXT,
Geo TEXT,
Period DATE,
Duration TEXT,
Industry TEXT,
Type TEXT,
Value REAL,
Unit TEXT,
Measure TEXT,
Multiplier INTEGER,
NullReason TEXT
)
''')
conn.commit() # Commit the changes
conn.close() # Close the connection
create_database_and_table('stats_nz_data.db')