I found a script to turn a mysql dump into an sqlite insertable code, and i am trying to get rid of trailing comma's before parentheses. (so the comma after 'DEFAULT NULL'. I use awk and gsub here and there. As you could guess I am not very familiar with regex.
CREATE TABLE "table_name" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"name" varchar(100) NOT NULL,
"created_at" datetime NOT NULL,
"deleted_at" datetime DEFAULT NULL,
);
At this point I use the following line in the script:
#Replace trailing commas
/\,\n\)/ { /\,\n\)/, "\, " }
But this gives me the following error
cmd. line:52: /\,\n\)/ { /\,\n\)/, "\, " }
awk: cmd. line:52: ^ syntax error
awk: cmd. line:52: warning: escape sequence `\,' treated as plain `,'
/\,\n\)/ { /\,\n\)/, "\, " }
awk: cmd. line:52: ^ syntax error
awk: cmd. line:52: warning: escape sequence `\,' treated as plain `,'
sql exported to stub-testdb.sqlite
Aucun commentaire:
Enregistrer un commentaire