Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update local development guide to help with demographic survey data imports #223

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading