Skip to content

[ENHANCEMENT] Allow the insertion of a schema and populate it with faker if desired #5

@SethCram

Description

@SethCram

Is your feature request related to a problem? Please describe.

  • Yes, currently need to upload database file

Describe the solution you'd like

  • Allow the insertion of a schema and populate it with faker if desired

Additional context

  • Should take in sqlite file, populate it with fake data thru insertions, then use tool to generate db file from it?
    • used 1 such tool to generate Chinook.db called sqlite3 with a .read operation

Development

  • allow upload of sql file and convert it to a database file using tool

    • had to call subprocess to startup a shell and feed dot cmd to that
      • otherwise would need to feed it SQL
      • which could be useful for direct SQL query running but not here
    • created a new method to fulfull this purpose
    • still needa verify whether sql should be written in byte mode or not
      • it prolly shouldn't so needa add an option to copy file in byte mode or not
    • still needa verify whether shutil.copyobj() overwrites pre-existing destination file
      or not
      • to test both of these before committing to an image
      • need to find out how to read a local file into a fileobject for reading + writing
      • documentation says "If dst specifies a file that already exists, it will be replaced."
    • verified that the sqlite3 tool overwrites destination file
  • stored uploaded sql files in a new directory

    • added a new SQL folder to contain them in backend args
    • created it at make_serve execution
      • gonna needa figure out how to run this cmd w/ deploying API
    • steps:
      • create db file from sql file
        • if fails, throw error bc sql not in proper format
      • if successful, save both files in their respective dirs
    • had to change the ordering of steps to account for saving the sql file before generating the db file
      • due to restrictions of sqlite3 tool
      • then if error occurs, have to delete uploaded sql file
    • had to copy in byte mode, even tho reading from SQL file
    • if file copying fails, had to delete the empty file that's created
    • decided to error out if pre-existing sql file that'll be overwritten
    • to add sql_path:
      • added to backend args
      • added to serve.json config
      • added dir creation + docker mounting of it to makefile
  • figure out how to generate fake data for unknown scheme or given a scheme

    • should be able to pass the file name
    • sql data generators online
      • not very user friendly
    • mockaroo seems promising thru their api https://www.mockaroo.com/
  • after fake data generated, should automatically generate db file and put it into proper folder

    • should overwrite pre-existing file in folder with db file name

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions