Skip to content

Commit

Permalink
Update local development guide to help with demographic survey data i…
Browse files Browse the repository at this point in the history
…mports (#223)
  • Loading branch information
dinoboy197 authored Aug 27, 2024
1 parent bb7ec8a commit 0866561
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion prisma/dataimport/dataimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
# Database connection parameters - adjust these to your own server
server = os.getenv('DB_SERVER')
database = os.getenv('DB_NAME')
userid = os.getenv('USERID')
pwd = os.getenv('PWD')

# Establish a connection
conn_str = f'DRIVER={{SQL Server}};SERVER={server};DATABASE={database};Integrated Security=true'
conn_str = f'DRIVER={{ODBC Driver 18 for SQL Server}};SERVER={server};DATABASE={database};Integrated Security=true;TrustServerCertificate=yes;UID={userid};PWD={pwd}'

conn = pyodbc.connect(conn_str)

Expand Down
3 changes: 2 additions & 1 deletion prisma/dataimport/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pandas==1.4.3
pyodbc==4.0.39
python-dotenv==1.0.0
python-dotenv==1.0.0
numpy==1.26.4
17 changes: 13 additions & 4 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Create a new database and check that it was created
CREATE DATABASE HIERR;
SELECT Name from sys.databases;
GO
exit
```

Then, you may exit:
Expand All @@ -41,9 +42,9 @@ exit
Prepare the HIERR container:

```bash
# instal curl in hierr container
docker exec -u 0:0 -it hierr-node-1 bash -c "apt update && apt install -y curl"
# open hierr container and run
# instal OS dependencies in HIERR container
docker exec -u 0:0 -it hierr-node-1 bash -c "apt update && apt install -y curl gpg && curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg && curl https://packages.microsoft.com/config/debian/12/prod.list | tee /etc/apt/sources.list.d/mssql-release.list && apt update && ACCEPT_EULA=Y apt install -y python3 python3-dev python3.11-venv gcc g++ libodbc2 msodbcsql18"
# open hierr container and install Node.js dependencies
docker exec -it hierr-node-1 bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
exit
Expand All @@ -60,6 +61,14 @@ Finally, run the DB migration scripts and run the dev server:
# still inside the HIERR container...
npx prisma migrate dev
npx prisma db push

# Load demographic survey questions
python3 -mvenv venv
source venv/bin/activate
cd prisma/dataimport
pip install -r requirements.txt
DB_SERVER='hierr-sql-1' DB_NAME='HIERR' USERID='SA' PWD='<YourStrong@Passw0rd>' python3 ./dataimport.py

# Run dev server on http://localhost:3000
npm run dev
```
Expand Down Expand Up @@ -235,7 +244,7 @@ Docs: https://www.prisma.io/docs/guides/database/developing-with-prisma-migrate/

In the .env file, add the following environment variable with the survey ids comma separated.

NEXT_PUBLIC_POLIS_SURVEYS='[{"id": "SurveyID1", "title": "SurveyTitle1", "description", "SurveyDescription1"}, ...]'
Read the dataimport readme and follow it's instructions.

# Exporting data from Pol.is survey data

Expand Down

0 comments on commit 0866561

Please sign in to comment.