-
-
Notifications
You must be signed in to change notification settings - Fork 26
Common Debugging Help
Thanks to this little gem in stack overflow, I found that there was an errant init.py
`get the V1.0.0 code from jobhopper. Start the server (assuming you've followed the README.md steps).
(venv) C:\Users\jedpi\OneDrive\Documents\GitHub>python jobhopper/manage.py runserver Watching for file changes with StatReloader Performing system checks...
System check identified no issues (0 silenced). September 22, 2020 - 21:37:18 Django version 3.1, using settings 'jobhopper.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. [22/Sep/2020 21:37:24] "GET /api/v1/health HTTP/1.1" 200 308 `
Go to this url and you'll get some json back: http://127.0.0.1:8000/api/v1/health
SECRET_KEY='ABx133o5tex' DB_NAME='jobhopperdatabase' DB_USER='jobuser' DB_PASSWORD='jobuser' DB_HOST='127.0.0.1
(venv) C:\Users\jedpi\OneDrive\Documents\GitHub>python jobhopper/manage.py test
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
Ran 2 tests in 0.047s
OK Destroying test database for alias 'default'...
Seed a database table with a csv (example provided was for states):
- you should have a postgres command line or query tool available and be familiar with it.
Goal: Given a table that django migrations have created, we want to, for dev purposes, seed with data (in this case state data) Steps:
/* since we decided this was the format of the data: { "id": 5, "state_name": "ARKANSAS", "abbreviation": "AR" }, */ -- create a fake table just to show the statement -- drop table jed_states_fake "State","Abbrev","Code" create table jed_states_fake(state varchar(255), abbrev varchar(255), code varchar(255)) -- grab the file from here (see csv link in middle) -- https://worldpopulationreview.com/states/state-abbreviations -- save to my postgres dir see below... that worked (otherwise no go) COPY jed_states_fake from 'C:\Program Files\PostgreSQL\12\csvData.csv' with (format csv) select * from jed_states_fake --Create a fake table to simulate whatever the table was in django...assuming same layout as json above create table states_fake_django_data (id serial, state_name varchar(255), abbreviation varchar(255)) --Copy just the relevant data to seed it. insert into states_fake_django_data(state_name, abbreviation) select state, code from jed_states_fake select * from states_fake_django_data --cleanup -- drop table jed_states_fake -- drop table states_fake_django_data
-- Some credit to: https://stackoverflow.com/questions/2987433/how-to-import-csv-file-data-into-a-postgresql-table