Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package dbi and reverse engineer #3

Open
wilcar opened this issue Dec 11, 2017 · 3 comments
Open

package dbi and reverse engineer #3

wilcar opened this issue Dec 11, 2017 · 3 comments

Comments

@wilcar
Copy link

wilcar commented Dec 11, 2017

Hello,
Very interesting !
Can we use dbi package to make a reverse engineer diagramm ?

   library(DBI)
   inscrits_nn<- dbConnect(odbc::odbc(),
   driver = "MySQL ODBC 5.3 Unicode Driver",
   database = "inscrits_nn",
   uid = "root",
   host = "localhost",
   port = 3306)
   dm <- as.data_model(inscrits_nn)

Message :
Error in UseMethod("as.data_model") :
no applicable method for 'as.data_model' applied to an object of class "c('MySQL', 'OdbcConnection',
'DBIConnection', 'DBIObject')"

@bergant
Copy link
Owner

bergant commented Dec 16, 2017

Yes, it is possible to reverse engineer from MySQL. All you have to do is an SQL query that returns all tables, columns and references. See existing queries for SQL Server and Postgres (https://github.com/bergant/datamodelr/tree/master/inst/sql).

Save the results in a data frame and then use as.data_model on this data.

@wilcar
Copy link
Author

wilcar commented Dec 17, 2017

Thank you for helping. but I need more help !

I ma connecting to local db witrh this code :

   library(DBI)
  inscrits_nn<- dbConnect(odbc::odbc(),
  driver = "MySQL ODBC 5.3 Unicode Driver",
  database = "inscrits_nn",
  uid = "root",
 host = "localhost",
  port = 3306)

Based on your read.me, I am note able to adapt this piece of code from "sqlserver" to my sql db

 sQuery <- dm_re_query("sqlserver")
 dm_northwind <- sqlQuery(con, sQuery, stringsAsFactors = FALSE, errors=TRUE)
odbcClose(con)

@SFrav
Copy link

SFrav commented May 19, 2020

Is there a translation of the SQL Server query to MySQL? I have started to work on it but it’s slow going. For example, sys.all_columns may equate to INFORMLTION_SCHEMA.columns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants