How can I load the sql file "dump" in sql alchemy

I have a large sql dump file ... with several CREATE TABLE and INSERT INTO . Is there a way to load all this data into SQLAlchemy sqlite database right away. I plan to use the introspective ORM from sqlsoup after creating 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 any way around this problem. It is possible to split the file with a regular expression or some kind of parser, but I don’t know enough SQL to get all the cases for a regular expression.

Any help would be greatly appreciated.

Will

EDIT: Since this seems important ... The dump file was created using the MySQL database, so it has a lot of commands / syntax that sqlite3 does not understand correctly.

+4
source share
2 answers

"or some kind of parser"
I found MySQL a great parser for MySQL dump files :)
You yourself said this: "so it has quite a few commands / syntax that sqlite3 does not understand correctly." Obviously, SQLite is not a tool for this task.
As for your specific mistake: without context (i.e. Tracing), I cannot say anything about it. Martelli or Skeet could probably have reached time and space and read your translator, but this is not so much for me.

+1
source

The SQL recognized by MySQL and SQL in SQLite is completely different. I suggest dumping the data of each table separately, and then loading the data into equivalent tables in SQLite.

Create tables in SQLite manually using a subset of the CREATE TABLE commands specified in the raw-dump file.

0
source

Source: https://habr.com/ru/post/1309617/


All Articles