gravityio

db

Dec 2nd, 2021 (edited)
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. local db = require("dbapi");
  2. local dbcl = db.connect("192.168.0.69:8080");
  3.  
  4. local args = {...};
  5.  
  6. local function writeFile(path, content)
  7. local file = fs.open(path, "w");
  8. file.write(content);
  9. file.close();
  10. end
  11.  
  12. if (not dbcl) then print("Could Not Connect."); return end
  13.  
  14. local function requestInput(req)
  15. write(req);
  16. return read();
  17. end
  18.  
  19. local fileName = args[1] or requestInput("Enter File Name: ");
  20. local localPath = args[2] or fileName:match("^.+/(.+)$") or fileName;
  21.  
  22. local file = dbcl:getFile(fileName);
  23. if (not file.exists) then print("No such file");
  24. else writeFile(localPath, file.content); end
Add Comment
Please, Sign In to add comment