|
@@ -169,8 +169,12 @@ def create_column(**kwargs):
|
169
|
169
|
return col
|
170
|
170
|
|
171
|
171
|
|
|
172
|
+## Converts a string to an sqlAlchemy column type
|
|
173
|
+#
|
|
174
|
+# @param strtype str: string describing the type of the column
|
|
175
|
+# @return SqlAlchemy column type
|
|
176
|
+# @raise NameError
|
172
|
177
|
def string_to_sqla_type(strtype):
|
173
|
|
- """ Convert a string to an sqlAlchemy column type """
|
174
|
178
|
if 'VARCHAR' in strtype:
|
175
|
179
|
return string_to_varchar(strtype)
|
176
|
180
|
else:
|
|
@@ -180,8 +184,11 @@ def string_to_sqla_type(strtype):
|
180
|
184
|
raise NameError("Unknown type '" + strtype + "'")
|
181
|
185
|
|
182
|
186
|
|
|
187
|
+## Converts a string like 'VARCHAR(XX)' (with XX an integer) to a SqlAlchemy varchar type
|
|
188
|
+#
|
|
189
|
+# @param vstr str: String to convert
|
|
190
|
+# @return SqlAlchemy.VARCHAR
|
183
|
191
|
def string_to_varchar(vstr):
|
184
|
|
- """ Convert a string like 'VARCHAR(XX)' (with XX an integer) to a SqlAlchemy varchar type"""
|
185
|
192
|
check_length = re.search(re.compile('VARCHAR\(([\d]+)\)', re.IGNORECASE), vstr)
|
186
|
193
|
column_length = int(check_length.groups()[0]) if check_length else None
|
187
|
194
|
return sql.VARCHAR(length=column_length)
|