Giter Club home page Giter Club logo

rmariadb's Introduction

RMariaDB

Build Status AppVeyor Build Status Coverage Status CRAN_Status_Badge CRAN RStudio mirror downloads

RMariaDB is a database interface and MariaDB driver for R. This version is aimed at full compliance with the DBI specification, as a replacement for the old RMySQL package.

Hello World

library(DBI)
# Connect to my-db as defined in ~/.my.cnf
con <- dbConnect(RMariaDB::MariaDB(), group = "my-db")

dbListTables(con)
dbWriteTable(con, "mtcars", mtcars)
dbListTables(con)

dbListFields(con, "mtcars")
dbReadTable(con, "mtcars")

# You can fetch all results:
res <- dbSendQuery(con, "SELECT * FROM mtcars WHERE cyl = 4")
dbFetch(res)
dbClearResult(res)

# Or a chunk at a time
res <- dbSendQuery(con, "SELECT * FROM mtcars WHERE cyl = 4")
while(!dbHasCompleted(res)){
  chunk <- dbFetch(res, n = 5)
  print(nrow(chunk))
}
# Clear the result
dbClearResult(res)

# Disconnect from the database
dbDisconnect(con)

Installation

Binary packages for OS X or Windows can be installed directly from CRAN:

install.packages("RMariaDB")

The development version from github:

# install.packages("devtools")
devtools::install_github("r-dbi/DBI")
devtools::install_github("r-dbi/RMariaDB")

Discussions associated with DBI and related database packages take place on R-SIG-DB. The website Databases using R describes the tools and best practices in this ecosystem.

Installation from source on Linux or OS X currently requires Oracle's libmysqlclient or the more modern MariaDB Connector/C. The latter works best in version 2.3.4/3.0.3 or later, with older versions character and blob columns do not work reliably.

MySQL client library

On recent Debian or Ubuntu install libmysqlclient-dev.

sudo apt-get install -y libmysqlclient-dev

On Fedora, CentOS or RHEL we need mysql-devel:

sudo yum install mysql-devel

Follow instructions to enable the MySQL yum repository if the above command attempts to install MariaDB files.

On OS X use mysql-connector-c from Homebrew:

brew install mysql-connector-c++

Connector/C

On recent Debian or Ubuntu install libmariadb-client-lgpl-dev. In Ubuntu 14.04 this was called libmariadbclient-dev.

sudo apt-get install -y libmariadb-client-lgpl-dev

On Fedora, CentOS or RHEL we need mariadb-devel:

sudo yum install mariadb-devel

On OS X use mariadb-connector-c from Homebrew:

brew install mariadb-connector-c

MariaDB configuration file

Instead of specifying a username and password in calls to dbConnect(), it's better to set up a MariaDB configuration file that names the databases that you connect to most commonly. This file should live in ~/.my.cnf and look like:

[database_name]
option1=value1
option2=value2

If you want to run the examples, you'll need to set the proper options in the [rs-dbi] group of any MariaDB option file, such as /etc/my.cnf or the .my.cnf file in your home directory. For a default single user install of MariaDB, the following code should work:

[rs-dbi]
database=test
user=root
password=

Acknowledgements

Many thanks to Christoph M. Friedrich, John Heuer, Kurt Hornik, Torsten Hothorn, Saikat Debroy, Matthew Kelly, Brian D. Ripley, Mikhail Kondrin, Jake Luciani, Jens Nieschulze, Deepayan Sarkar, Louis Springer, Duncan Temple Lang, Luis Torgo, Arend P. van der Veen, Felix Weninger, J. T. Lindgren, Crespin Miller, and Michal Okonlewski, Seth Falcon and Paul Gilbert for comments, suggestions, bug reports, and patches to the original RMySQL package, and to all contributors (of code and discussions) to this package.


Please note that the 'RMariaDB' project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

rmariadb's People

Contributors

krlmlr avatar hadley avatar jeroen avatar jeffreyhorner avatar tschiefer avatar peternowee avatar nbenn avatar gagern avatar gaborcsardi avatar ggrothendieck avatar jph98 avatar rjoomen avatar renkun-ken avatar mcol avatar noahwilliamsson avatar stevenranney avatar jinzhen-lin avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.