xavdid / reddit-user-to-sqlite

Pull Reddit user data into a SQLite database
https://pypi.org/project/reddit-user-to-sqlite/
MIT License
215 stars 9 forks source link

Ignorant to what am I doing wrong with metadata.json #21

Closed rarelygoeshere closed 1 year ago

rarelygoeshere commented 1 year ago

Hello, I've recently come to be aware of this from your post on reddit, and I've been struggling with the final step of creating a metadata.json file, as I keep getting the error seen in file attached. Changing the txt file into .json seems easy enough, and copy pasting the content was too, yet when I ran datasette reddit.db --metadata metadata.json, it didn't work. I hope you might be able to help me understand this

Disclaimer: I'm very new to datasette and am a layman in general, with very few, if any, knowledge of CLI, so I hope you may excuse my ignorance on things. Thank you. screenshot_1687679280

xavdid commented 1 year ago

No worries at all! CLI can be tough.

I've got two questions-

  1. Does running datasette work for you if you don't include the --metadata arg?
  2. do both metadata.json and reddit.db show up if you run the dir command?
rarelygoeshere commented 1 year ago

Hello there, thanks for stopping by! Here are my answers to your questions:

  1. Running datasette seems to work fine for me without --metadata, as other cmds like --help and --open appears to be normal, as seen below. screenshot_1687720337 screenshot_1687720171 screenshot_1687720162

Just out of curiosity, I typed datasette reddit.db --metadata metadata.json sans --metadata and the result obviously didn't do anything. screenshot_1687720469

  1. It appears neither metadata.json or reddit.db shows up for me when I input dir. I did it 2 times, as seen below. Dir command C drive Dir command C drive 2

Hope these answers help your assessment!

xavdid commented 1 year ago

Ah, cool.

So when you run CLI commands, they're run from a directory (known as the "current directory"). From your screenshots, it looks like you're in C:\Users\admin-pc and then the root of your C:\ drive.

Datasette looks for the reddit.db (and metadata.json) in the directory you run the command from. So if the reddit.db file isn't in C:\Users\admin-pc, then you get the error you're seeing.

To fix this, you need to do 2 things:

  1. Find where your reddit.db file is
  2. use the cd (change directory) command to navigate your terminal to where that file is

Once there, datasette will work as expected. If you put metadata.json in that folder as well, it'll get picked up automatically.

Does that make sense?

rarelygoeshere commented 1 year ago

Ah, cool.

So when you run CLI commands, they're run from a directory (known as the "current directory"). From your screenshots, it looks like you're in C:\Users\admin-pc and then the root of your C:\ drive.

Datasette looks for the reddit.db (and metadata.json) in the directory you run the command from. So if the reddit.db file isn't in C:\Users\admin-pc, then you get the error you're seeing.

To fix this, you need to do 2 things:

  1. Find where your reddit.db file is
  2. use the cd (change directory) command to navigate your terminal to where that file is

Once there, datasette will work as expected. If you put metadata.json in that folder as well, it'll get picked up automatically.

Does that make sense?

Ahh, I see, then. That makes sense. I'll do so right away. Edit: Oh wow! It worked! I did what you instructed, and it looks like everything is now in working order! screenshot_1687723614 screenshot_1687723598 screenshot_1687723581 All right! Im quite certain my datasette is now complete. Thank you kindly for your instructions, I really appreciate your help!

xavdid commented 1 year ago

Awesome! Glad that worked out. I'll go ahead and close this, but I hope this has been illuminating 😅