@@ -23,13 +23,34 @@ class CovidHospSomething:
23
23
24
24
YAML_FILENAME = 'covid_hosp_schemadefs.yaml'
25
25
26
- TYPE_MAPPING = {
26
+ PYTHON_TYPE_MAPPING = {
27
27
'int' : int ,
28
28
'float' : float ,
29
29
'str' : str ,
30
30
'fixedstr' , str ,
31
+ 'bool' : int , # UNCOMMENT: Utils.parse_bool,
31
32
'intdate' : int , # UNCOMMENT: Utils.int_from_date,
32
- 'point' : str , # UNCOMMENT: Utils.limited_geocode,
33
+ 'geocode' : str , # UNCOMMENT: Utils.limited_geocode,
34
+ }
35
+
36
+ SQL_TYPE_MAPPING = {
37
+ 'int' : 'INT' ,
38
+ 'float' : 'DOUBLE' ,
39
+ 'str' : 'VARCHAR' ,
40
+ 'fixedstr' : 'CHAR' ,
41
+ 'bool' : 'TINYINT(1)' ,
42
+ 'intdate' : 'INT(11)' ,
43
+ 'geocode' : 'VARCHAR(32)' ,
44
+ }
45
+
46
+ SOURCE_METADATA_TYPE_MAPPING = {
47
+ 'int' : 'number' ,
48
+ 'float' : 'number' ,
49
+ 'str' : 'text' ,
50
+ 'fixedstr' : 'text' ,
51
+ 'bool' : 'checkbox/text' ,
52
+ 'intdate' : 'calendar_date' ,
53
+ 'geocode' : 'point' ,
33
54
}
34
55
35
56
MYSQL_COL_NAME_PATTERN = re .compile (r'^[a-zA-Z0-9_]{3,64}$' )
@@ -74,7 +95,7 @@ def columns(self, ds_name):
74
95
else :
75
96
dtype = dtype_cplx
76
97
col_width = None
77
- yield {'name' : name , 'sql_name' : sql_name , 'dtype' : dtype , 'col_width:' col_width , 'marshaller' : CovidHospSomething .TYPE_MAPPING [dtype ]}
98
+ yield {'name' : name , 'sql_name' : sql_name , 'dtype' : dtype , 'col_width:' col_width , 'marshaller' : CovidHospSomething .PYTHON_TYPE_MAPPING [dtype ]}
78
99
79
100
80
101
def add_column (self , ds_name , col_name , dtype , sql_name = None , col_width = None ):
@@ -135,6 +156,7 @@ def write_new_definitions(self):
135
156
# write migration file for new columns
136
157
with open (migration_file , 'w' ) as f :
137
158
# TODO
159
+ # NOTE: we dont have column differences here, this cant stay here without that
138
160
f .write ("\n " )
139
161
140
162
# move files into proper locations
0 commit comments