I have need to migrate some sqlite3 databases to mysql for a couple django-cms projects at work. Typically in the past I’ve used fixtures in Django to get this done, but I usually have to align the planets and concoct the elixir of life to get the fixtures to migrate properly. It usually has to do with foreign key errors something. This is something that should just be easy, but in my experience with Django, it never is.
defmain(): print"SET sql_mode='NO_BACKSLASH_ESCAPES';" for line in sys.stdin: processLine(line)
defprocessLine(line): if ( line.startswith("PRAGMA") or line.startswith("BEGIN TRANSACTION;") or line.startswith("COMMIT;") or line.startswith("DELETE FROM sqlite_sequence;") or line.startswith("INSERT INTO \"sqlite_sequence\"") ): return line = line.replace("AUTOINCREMENT", "AUTO_INCREMENT") line = line.replace("DEFAULT 't'", "DEFAULT '1'") line = line.replace("DEFAULT 'f'", "DEFAULT '0'") line = line.replace(",'t'", ",'1'") line = line.replace(",'f'", ",'0'") in_string = False newLine = '' for c in line: ifnot in_string: if c == "'": in_string = True elif c == '"': newLine = newLine + '`' continue elif c == "'": in_string = False newLine = newLine + c print newLine
This post is a bit of a ‘note to self’. I am tinkering with Vagrant boxes today trying to flesh out some ansible and I need to get the boxes to talk to each other locally. I know about the vagrant multi-machine setup, but I was already partly committed to having 2 individual boxes set up before I discovered it.
So, the trick is, set the network configuration in your Vagrantfile to “private_network”: