I'm using mdb-tools on FreeBSD to convert a Microsoft Access DB to MySQL.
The script looks like this (to_mysql.sh
):
#!/usr/local/bin/bash
echo "DROP TABLE IF EXISTS Student;"
mdb-schema -T Student $1 mysql
mdb-export -D '%Y-%m-%d %H:%M:%S' -I mysql $1 Student
And I'm using it like:
./to_mysql.sh accessDb.MDB > data.sql
The problem is that the GUID
(the second column) in the mdb changes for all rows.
In the access DB one row looks like this:
|{D115266B-D5A3-4617-80F8-7B80EE3022DA}|2013-06-11 08.54.14|2015-12-17 14.57.01|2|2||||||0|111111-1111||Nameson|Name|||||3|||SA|0||||0|Gatan 2|222 22|1234 567
And when I convert it to MySQL using the script above it looks like this:
INSERT INTO `Student` (
`UsedFields`,`GUID`,`Changed`,`ChangedLesson`,`AccessInWebViewer`,`VisibleInWebViewer`
,`PasswordInWebViewer`,`Language`,`UserMan`,`SchoolID`,`Owner`,`DoNotExport`
,`Student`,`Category`,`LastName`,`FirstName`,`Signature`,`Sex`
,`Phone`,`SchoolType`,`Grade`,`EMail`,`Program`,`IgnoreLunch`
,`ExcludedTime`,`Individual timetable`,`Adress(TEXT) `,`Postnr(TEXT) `
,`Ort(TEXT) `
)
VALUES (
NULL,"{266bd115-d5a3-4617-f880-807b30eeda22}","2013-06-11 08:54:14"
,"2015-12-17 14:57:01",2,2,NULL,NULL,NULL,NULL,NULL,0,"111111-1111"
,NULL,"Nameson","Name ",NULL,NULL,NULL,NULL,"3",NULL,"SA"
,0,NULL,0,"Gatan 2","222 22","1234 567"
);
Everything is correct except the GUID column, it changes from:
{D115266B-D5A3-4617-80F8-7B80EE3022DA}
to
{266bd115-d5a3-4617-f880-807b30eeda22}
It looks like all the chars just reordering, but I have no idea why.
Does anyone know why and how I can prevent this?
Thank you!
seems like a byte order issue in mdbtools. for a workaround create a small sed script ''mdb_fixguids'', something like
put it into the path and use it in the conversion pipe, something like
BTW :) this is the first time I needed all the possible backrefs in sed