How can I load a sql "dump" file into sql alchemy
I have a large sql dump file ... with multiple CREATE TABLE
and INSERT INTO
statements. Is there any way to load these all into a SQLAlchemy sqlite database at once. I plan to use the introspected ORM from sqlsoup
after I've created the tables. However, when I use the engine.execute()
method it complains: sqlite3.Warning: You can only execute one statement at a time.
Is there a way to work around this issue. Perhaps splitting the file with a r开发者_StackOverflow社区egexp or some kind of parser, but I don't know enough SQL to get all of the cases for the regexp.
Any help would be greatly appreciated.
Will
EDIT: Since this seems important ... The dump file was created with a MySQL database and so it has quite a few commands/syntax that sqlite3 does not understand correctly.
"or some kind of parser"
I've found MySQL to be a great parser for MySQL dump files :)
You said it yourself: "so it has quite a few commands/syntax that sqlite3 does not understand correctly." Clearly then, SQLite is not the tool for this task.
As for your particular error: without context (i.e. a traceback) there's nothing I can say about it. Martelli or Skeet could probably reach across time and space and read your interpreter's mind, but me, not so much.
The SQL recognized by MySQL and the SQL in SQLite are quite different. I suggest dumping the data of each table individually, then loading the data into equivalent tables in SQLite.
Create the tables in SQLite manually, using a subset of the "CREATE TABLE" commands given in your raw-dump file.
精彩评论