SQL Translator (SQLFairy) - 'Invalid statement: Was expecting comment, or use, or set, or drop'

StackOverflow https://stackoverflow.com/questions/17911384

  •  04-06-2022
  •  | 
  •  

문제

Environment

Fedora 19 and MariaDB on VirtualBox in Windows 7

Installation

yum install perl-SQL-Translator

Steps

Generate dump with:

[username@hostname ~] mysqldump -u root -pmysql_root_password database_name > example.sql

Generate diagram with:

[username@hostname ~]  sqlt-graph -f MySQL -o example.png -t png example.sql

Error

ERROR (line 36): Invalid statement: Was expecting comment, 
or use, or set, or drop, or create, or alter, or insert, or 
delimiter, or empty statement
Error: translate: Error with parser 'SQL::Translator::Parser::MySQL':  
no results at /usr/bin/sqlt-graph line 195.

Links

SQLFairy

Edit

Error also occurs in the following SQL on line 5:

DROP TABLE IF EXISTS `test_table`;
CREATE TABLE `test_table` (
  `my_id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`my_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
LOCK TABLES `test_table` WRITE;
UNLOCK TABLES;
도움이 되었습니까?

해결책

The solution for this would be that you export only your table defintions of your schema. The error in your example should btw. not occur on line five but on line six where the table gets locked for inserting data.

As a solution dump your schema without the data, given your example above you can do the following to get a dump which is working with the fairy:

mysqldump -u root -pmysql_root_password --no-data database_name > example.sql
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top