-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_meta_tables.py
More file actions
63 lines (43 loc) · 1.12 KB
/
create_meta_tables.py
File metadata and controls
63 lines (43 loc) · 1.12 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 14 10:42:40 2026
@author: vicky
"""
import mysql_indexes
import os
import pymysql
import sqlalchemy
from sqlalchemy import URL
import tables
import db_connection as db
import setup_raw_data_table as setup
#%% ###### connect to database ####
# call db_connection
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="yourusername",
password="yourpassword",
database="mydatabase"
)
## check if table exists
mycursor = mydb.cursor()
mycursor.execute("SHOW TABLES")
## create any missing tables
for x in mycursor:
if 'station_metadata' and 'organization' in x:
continue_flag = 0
elif 'organization' in x:
continue_flag = 1
elif 'station_metadata' in x:
continue_flag = 2
# get metadata from json file
def set_up_metadata_table(continue_flag):
if continue_flag == 1:
create_organiztion_table()
elif continue_flag == 2:
create_stationmetadata_table()
def create_organiztion_table():
def create_stationmetadata_table():
tables.add__table()