Y
Y
York Princess2019-10-06 15:14:50
MySQL
York Princess, 2019-10-06 15:14:50

How to correctly deploy multiple tables when reading from a .sql file?

There is a file .sql in which tables are described. There is a python3 script that reads from this file and executes what is read as a request. The module for working with the database is pymysql.
Error 1064 (syntax error) occurs when executing:

1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CREATE TABLE `History` (\n\t`id` INT NOT NULL,\n\t`item_id` INT NOT NULL,\n\t`date` D' at line 15"

*line 13 ends the description of the first table, line 14 is a line break, line 15 is the description of the next table.
I am extremely confused by the presence of any \n and \t in this line. I've tried replacing these special characters with an empty string and a space, but to no avail. If you leave only one table in the file, then everything works correctly.
The contents of the file are 100% correct, checked through the console on the same computer.
The feeling that the problem is some kind of stupid, but so far I don’t understand what else can be done, but the problem is definitely in special characters.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
York Princess, 2019-10-06
@Princess_York

The solution was found: https://stackoverflow.com/questions/36946444/readi...
Apparently, execute cannot do a lot of requests at once, so you have to execute them one by one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question