Spaces:
Running
Running
Your Name
Feature release: Added Interrupted Time Series (ITS) module with Bai-Perron auto-detect and counterfactual modeling. Integrated Excel report generation and refined Dashboard UI/UX.
359a85c Download setup_database.sql from phantomas34/perfect-margin: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/spaces/phantomas34/perfect-margin/resolve/main/setup_database.sql
- Command line
-
hf download hf://spaces/phantomas34/perfect-margin/setup_database.sql
-
curl -L -o setup_database.sql https://huggingface.co/spaces/phantomas34/perfect-margin/resolve/main/setup_database.sql
1.32 kB
| library(DBI) | |
| library(RPostgres) | |
| library(readr) # To read your .sql file | |
| sys_con <- dbConnect(RPostgres::Postgres(), | |
| dbname = "postgres", # Default system DB | |
| host = "localhost", | |
| user = "postgres", | |
| password = "your_password_here") # | |
| tryCatch({ | |
| dbExecute(sys_con, "CREATE DATABASE sales_db;") | |
| print("Database 'sales_db' created successfully.") | |
| }, error = function(e) { | |
| print("Database 'sales_db' already exists or could not be created.") | |
| }) | |
| dbDisconnect(sys_con) # Disconnect from system DB | |
| con <- dbConnect(RPostgres::Postgres(), | |
| dbname = "sales_db", | |
| host = "localhost", | |
| user = "postgres", | |
| password = "ggdata2014") # | |
| sql_commands <- read_file("database.sql") | |
| statements <- unlist(strsplit(sql_commands, ";")) | |
| # Execute each statement | |
| for (stmt in statements) { | |
| # clean up whitespace | |
| stmt_clean <- trimws(stmt) | |
| if (nchar(stmt_clean) > 0) { | |
| tryCatch({ | |
| dbExecute(con, stmt_clean) | |
| print(paste("Executed:", substr(stmt_clean, 1, 50), "...")) | |
| }, error = function(e) { | |
| print(paste("Error executing:", substr(stmt_clean, 1, 50))) | |
| print(e) | |
| }) | |
| } | |
| } | |
| print("Tables created successfully!") | |
| dbDisconnect(con) |