Skip to content

ohkinozomu/runsqldef

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

runsqldef

Embedding sqldef into a program using FFI

Node.js

npm install runsqldef
import path from "path";
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import { runSqldef } from "runsqldef";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const dbType = "postgres";
const dbName = "your_db_name";
const user = "your_user";
const password = "your_password";
const host = "your_host";
const port = "5432";
const schemaFile = path.resolve(__dirname, "path/to/your/schema.sql");
const enableDropTable = 0;

const result = runSqldef(dbType, dbName, user, password, host, port, schemaFile, enableDropTable);
if (result !== 0) {
  console.error("Error running schema tool");
} else {
  console.log("Schema tool ran successfully");
}