Description Usage Arguments Examples
View source: R/update_db_info.R
Creates the SQL Connection and creates/Reads the db_fields .csv file according to the db_fields standard and according to what the SQL database looks like
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  | initialise_return_db_fields(
  csv_path,
  Driver,
  Database,
  Server,
  UID,
  PWD,
  Trusted_Connection,
  Port = 1433,
  ...,
  ForceCreate_csv = FALSE,
  ExcludeIdentities = FALSE,
  ExcludeForeignKeys = TRUE,
  Update_DBEnv_DBFields = FALSE,
  ExcludeAuditingFields = FALSE,
  ExcludeSYSDIAGRAMS = TRUE,
  RegexToSelectTables = "^(DIM_|FACT_|TBL_)",
  UpdateDBFieldsFromDBCon = FALSE,
  DefaultToExclude = FALSE
)
 | 
csv_path | 
 A String. The path of the db_fields .csv file to read (or to be created if it doesn't exist)  | 
Driver | 
 A string. A SQL Driver, etc.: SQL Server;  | 
Database | 
 A string. The name of the SQL Database itself  | 
Server | 
 A string. A name that resolves into the SQL Machine, or the IP to the SQL Machine  | 
UID | 
 A string. The Username credential for the SQL Connection. NULL if Windows Login is to be used  | 
PWD | 
 A string. The Password credential for the SQL Connection. NULL if Windows Login is to be used  | 
Trusted_Connection | 
 A Boolean. TRUE or FALSE on whether Windows Login is to be used, if a string is used it'll be passed as is.  | 
Port | 
 An Integer. The Port which the SQL Listener is listening at  | 
... | 
 If the relationships exist on the SQL Database, this can be left blank. Logical expressions for the SQL Relationships in the format: table1$FKcolumn1 == table2$IDcolumn5, table1$FKcolumn2 == table3$IDcolumn5, ...  | 
ForceCreate_csv | 
 A Boolean. If TRUE then even if the db_fields exist, it will be deleted and overwriten by a newly created default db_fields  | 
ExcludeIdentities | 
 A Boolean. The default inclusion behaviour for SQL Table Identities. If we're going to perform more joins afterwards or if we need to have a reference as to which table each column belongs to, then we shouldn't exclude them; if we only care about extrapolating information from each specific row, then we can exclude them by default and edit to include just the row identifier ID.  | 
ExcludeForeignKeys | 
 A Boolean. If we need to perform manual joins afterwards or keep a reference as to with which table there's a connection, then we need them; otherwise we can safely exclude them  | 
Update_DBEnv_DBFields | 
 A Boolean. If set to TRUE, you can have an internal main db_fields accessible via db$db_fields usually acting as the main db_fields. Default is FALSE as having local db_fields variables is the default behaviour.  | 
UpdateDBFieldsFromDBCon | 
 A Boolean. If set to TRUE, then the db_fields saved on the file will be updated to reflect any changes in the SQL Database (removal or addition of Columns and Tables). User options are kept.  | 
DefaultToExclude | 
 A Boolean. If TRUE, every non-ID and non-FK column will default to Include == FALSE, unless ExcludeIdentities or ExcludeForeignKeys is set to TRUE  | 
ExcludeAuditingFields. | 
 A Boolean. If TRUE, any SQL Columns ending with "_OrigEntryOn", "_OrigEntryBy", "_EntryOn", "_EntryBy", "_CompName", "_Remote" or "_Username" will have INCLUDE == FALSE by default  | 
ExcludeSYSDIAGRAMS. | 
 A Boolean. If TRUE, any SQL Columns on the table "sysdiagrams" will have INCLUDE == FALSE by default  | 
RegexToSelectTables. | 
 A String. It defaults to getting all SQL Tables whose name begins with DIM_, FACT_, or TBL_.  | 
1 2 3 4 5 6 7 8 9 10 11 12 13 14  | db_fields <- initialise_return_db_fields(csv_path = "db_fields.csv",
                                         ForceCreate_csv = FALSE,
                                         ExcludeIdentities = FALSE,
                                         ExcludeForeignKeys = TRUE,
                                         Driver = "{SQL Server};",
                                         Database = "MyDatabaseName",
                                         Server = "123.456.7.8",
                                         UID = NULL,
                                         PWD = NULL,
                                         Trusted_Connection = TRUE,
                                         Port = 1433,
                                         table1$FKcolumn2 == table2$IDcolumn1,
                                         table1$FKcolumn3 == table3$IDcolumn1
                                         )
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.