# Mysql adapter & 2 statments

**URL:** <https://www.ruby-forum.com/t/mysql-adapter-2-statments/187987>\
**Category:** Rails\
**Created:** [May 3, 2010, 7:43pm UTC](https://www.ruby-forum.com/t/mysql-adapter-2-statments/187987 "2010-05-03T19:43:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![briseis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9d8465/32.png) [@briseis](https://www.ruby-forum.com/u/briseis)\
**Post date:** [May 3, 2010, 7:43pm UTC](https://www.ruby-forum.com/t/mysql-adapter-2-statments/187987/1 "2010-05-03T19:43:34Z")

</div>

Hi,

I have an error with mysql adapter when where is two statment in the  
same sql execution.  
I don’t have this error with postgres adapter.

If I perform, on the console, this “stupide” code :

> db = ctiveRecord::Base.connection  
> db.execute(" db.execute(“CREATE TABLE toto (id int); DROP TABLE toto;”)

I have the error :

//////////////////

ActiveRecord::StatementInvalid: Mysql::Error: You have an error in your  
SQL syntax; check the manual that corresponds to your MySQL server  
version for the right syntax to use near ‘DROP TABLE toto’ at line 1:  
CREATE TABLE toto (id int); DROP TABLE toto;  
from  
/Library/WebServer/Documents/RubyTimeNetV2/vendor/plugins/rows\_logger/init.rb:36:in  
`log' from /Library/WebServer/Documents/RubyTimeNetV2/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:304:in`execute\_without\_query\_stats’  
from  
/Library/WebServer/Documents/RubyTimeNetV2/vendor/plugins/query\_stats/lib/query\_stats/recorder.rb:16:in  
`execute' from /Library/WebServer/Documents/RubyTimeNetV2/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in`realtime’  
from  
/Library/WebServer/Documents/RubyTimeNetV2/vendor/plugins/query\_stats/lib/query\_stats/recorder.rb:15:in  
`execute’  
from (irb):116

////////////////

If I separate the two (stupids) statment, no error :

> > db.execute(“CREATE TABLE toto (id int);”)  
> > =\> nil
> 
> > db.execute(“DROP table toto;”)  
> > =\> nil

Thanks

Laurent

---

<div class="post-metadata">

**Author:** ![briseis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9d8465/32.png) [@briseis](https://www.ruby-forum.com/u/briseis)\
**Post date:** [May 3, 2010, 7:45pm UTC](https://www.ruby-forum.com/t/mysql-adapter-2-statments/187987/2 "2010-05-03T19:45:25Z")

</div>

> > db = ActiveRecord::Base.connection  
> > db.execute(“CREATE TABLE toto (id int); DROP TABLE toto;”)

Sorry for this typo.

Laurent
