mirror of
https://github.com/haiwen/seahub.git
synced 2025-04-27 11:01:14 +00:00
Fix sqlite2mysql script problems with seahub_db (#5274)
* scripts/sqlite2mysql: Fix non matching regex Regex was not matching for seahub.db export. e.g. 'CREATE TABLE IF NOT EXISTS "django_content_type" (...' was not matching. * fix default value quotation. * Update sqlite2mysql.py
This commit is contained in:
parent
c7918cdf56
commit
4d38b49941
@ -41,7 +41,7 @@ for line in fileinput.input():
|
||||
if re.match(r'^CREATE TABLE.*', line):
|
||||
searching_for_end = True
|
||||
|
||||
m = re.search('CREATE TABLE [`"]?(\w*)[`"]?(.*)', line)
|
||||
m = re.search('CREATE TABLE(?: IF NOT EXISTS)? [`"]?(\w+)[`"]?(\s*\(.*)', line)
|
||||
if m:
|
||||
name, sub = m.groups()
|
||||
sub = sub.replace('"','`')
|
||||
@ -67,6 +67,9 @@ for line in fileinput.input():
|
||||
# replace " and ' with ` because mysql doesn't like quotes in CREATE commands
|
||||
line = line.replace('"', '`').replace("'", '`')
|
||||
|
||||
# fix default values parantheses
|
||||
line = re.sub(r"default `([^`]*)`", r"default '\1'", line, 0, re.IGNORECASE)
|
||||
|
||||
# And now we convert it back (see above)
|
||||
if re.match(r".*, ``\);", line):
|
||||
line = re.sub(r'``\);', r"'');", line)
|
||||
|
Loading…
Reference in New Issue
Block a user