【发布时间】:2017-11-09 15:53:52
【问题描述】:
我编写了一些与 SQL 一起使用的函数。我使用testthat 和内存中的 SQLite 数据库测试这些函数。但是,某些功能无法使用 SQLite 进行测试,因为 SQLite does not support the ALTER TABLE command。
有什么方法可以像模拟 SQLite 一样模拟内存中的 mySQL 数据库吗?
> DBI::dbConnect(RSQLite::SQLite(), ":memory:")
<SQLiteConnection>
Path: :memory:
Extensions: TRUE
> DBI::dbConnect(RMySQL::MySQL(), ":memory:")
Error in .local(drv, ...) :
Failed to connect to database: Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
如果没有,如何为 mySQL 函数编写自动测试?
【问题讨论】: