Skip to content

Instantly share code, notes, and snippets.

@thigm85
Last active December 17, 2015 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thigm85/5608119 to your computer and use it in GitHub Desktop.
Save thigm85/5608119 to your computer and use it in GitHub Desktop.
This is the first step to establish a simple and free database to hold stock quotes downloaded from Yahoo Finance!
require(ODB)
database_path = "~/example_path/my_database.odb"
# Create a database
odb.create(database_path)
# Connect to the database
ODB <- odb.open(database_path)
# Creation of a new table to hold future data from Yahoo Finance!
SQL <- "CREATE TABLE stock (id INTEGER PRIMARY KEY, date DATE, open DOUBLE, high DOUBLE, low DOUBLE, close DOUBLE, volume DOUBLE, adjclose DOUBLE, name VARCHAR(10))"
odb.write(ODB, SQL)
# Save changes and close connection
odb.close(ODB, write = TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment