Anyone know a quick easy way to migrate a SQLite3 database to MySQL?
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- SQL/SQL-LITE - Counting records after filtering
- Why sometimes there is one of more gap(s) in the v
fallino correctly identified the location of the error in the script. I have the solution. The problem is the following lines:
The replacement pattern (2nd parameter) in the re.sub calls is a "regular" string, so instead of \1 expanding to the first regexp match, it expands to a literal 0x01. Likewise, \2 expands to 0x02. For example, a line containing: ,'t','f', would be replaced with: <0x01>10<0x02>
(First substitution changes ,'t', to <0x1>1<0x2> Second substitution changes <0x02>'f', to <0x1>0<0x1>)
The fix is to either change the replacement strings by adding an 'r' prefix, or by escaping the \1 and \2 in the existing string. Since easy manipulation of regexp strings is what raw strings are for, here's the fix using those:
I wrote this simple script in Python3. It can be used as an included class or standalone script invoked via a terminal shell. By default it imports all integers as
int(11)
and strings asvarchar(300)
, but all that can be adjusted in the constructor or script arguments respectively.NOTE: It requires MySQL Connector/Python 2.0.4 or higher
Here's a link to the source on GitHub if you find the code below hard to read: https://github.com/techouse/sqlite3-to-mysql/blob/master/sqlite3mysql.py