Update migrate.py for better name migrations

This commit is contained in:
2023-08-18 20:54:23 +02:00
parent af94afaa62
commit 495ba4d7d2
3 changed files with 133 additions and 69 deletions

View File

@ -7,6 +7,7 @@ import re
import datetime
import csv
RE_SPACES = re.compile(r'\s+')
RE_INT = re.compile(r'-?[0-9]+')
RE_FLOAT = re.compile(r'-?[0-9]+\.[0-9]+')
RE_STR_START = re.compile(r'.*,"[^"]*$')
@ -17,6 +18,10 @@ def sqlite_regexp(pattern: str, value: Optional[str]) -> Optional[bool]:
return re.match(pattern, value) is not None if value is not None else None
def remove_spaces(s: str) -> str:
return RE_SPACES.sub(' ', s).strip()
def cast_value(value: str) -> Any:
if value == '':
return None