diff --git a/prisma/dataimport/dataimport.py b/prisma/dataimport/dataimport.py index c826c81..68e08b5 100644 --- a/prisma/dataimport/dataimport.py +++ b/prisma/dataimport/dataimport.py @@ -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) diff --git a/prisma/dataimport/requirements.txt b/prisma/dataimport/requirements.txt index a3ae633..f25f08b 100644 --- a/prisma/dataimport/requirements.txt +++ b/prisma/dataimport/requirements.txt @@ -1,3 +1,4 @@ pandas==1.4.3 pyodbc==4.0.39 -python-dotenv==1.0.0 \ No newline at end of file +python-dotenv==1.0.0 +numpy==1.26.4 diff --git a/src/README.md b/src/README.md index de70e8b..e1b3949 100644 --- a/src/README.md +++ b/src/README.md @@ -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: @@ -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 @@ -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='' python3 ./dataimport.py + # Run dev server on http://localhost:3000 npm run dev ``` @@ -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