Skip to content

Commit a245dd4

Browse files
authored
Merge pull request #365 from grillazz/master
minor changes to project
2 parents 1356cdf + 8e3fd93 commit a245dd4

8 files changed

Lines changed: 739 additions & 40 deletions

File tree

samples/development-frameworks/SqlServerOnDocker/README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@ Prof of concept project with Microsoft SQL Server and Django Framework setup on
44
## To start development:
55
1. install [docker](https://docs.docker.com/#/components) and [docker-compose](https://docs.docker.com/compose/install/)
66
2. clone this repository
7-
2. run `docker-compose build db` to build db container
8-
2. sudo docker-compose run db sqlcmd -S db1.internal.prod.example.com -U SA -P 'Alaska2017' -Q 'create database docker2;'
9-
3. run `docker-compose up web` to test web and db containers
10-
5. run `docker-compose run web python3 manage.py migrate` to apply migrations. **Important! all migrations will go to master database unless you create new database and update settings.py files**
11-
6. run `docker-compose run web python3 manage.py createsuperuser` to create admin account
7+
3. run `docker-compose build db` to build db container
8+
4. run `docker-compose up -d db` to run SQL Server container in detached mode in the background
9+
5. run `docker-compose run db sqlcmd -S db1.internal.prod.example.com -U SA -P 'Alaska2017' -Q "RESTORE FILELISTONLY FROM DISK = N'/var/opt/mssql/backup/AdventureWorksDW2017.bak'"`
10+
to verify database file names before restore,
11+
6. run `docker-compose run db sqlcmd -S db1.internal.prod.example.com -U SA -P 'Alaska2017' -Q "RESTORE DATABASE AdventureWorksDW2017 FROM DISK = N'/var/opt/mssql/backup/AdventureWorksDW2017.bak' WITH MOVE 'AdventureWorksDW2017' TO '/var/opt/mssql/data/AdventureWorksDW2017.mdf', MOVE 'AdventureWorksDW2017_log' TO '/var/opt/mssql/data/AdventureWorksDW2017_log.ldf' "`
12+
to restore AdventureWorksDW2017 database on SQL Server
13+
7. run `docker-compose run web python3 manage.py migrate` to apply migrations on default database. In this case it will be AdventureWorksDW2017.
14+
8. run `docker-compose run web python3 manage.py createsuperuser` to create admin account
1215

1316
## To run project:
14-
1.
17+
1518
1. run `docker-compose up web`
1619
2. point your browser to `localhost:8080`
1720
3. press `CTRL+C` to stop
1821

1922
## Access to sql server
20-
1. sudo docker-compose run db sqlcmd -S db1.internal.prod.example.com -U SA -P 'Alaska2017' -Q 'select 1'
21-
2. sudo docker exec -it sqlserverondocker_db_1 bash
23+
1. sudo docker-compose run db sqlcmd -S db1.internal.prod.example.com -U SA -P 'Alaska2017' -Q 'select 1 from AdventureWorksDW2017'
24+
2. sudo docker exec -it sqlserverondocker_db_1 bash

samples/development-frameworks/SqlServerOnDocker/SqlServerOnDocker/settings.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""
22
Django settings for SqlServerOnDocker project.
33
4-
Generated by 'django-admin startproject' using Django 1.10.5.
4+
Generated by 'django-admin startproject' using Django 2.0.2.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/1.10/topics/settings/
7+
https://docs.djangoproject.com/en/2.0/topics/settings/
88
99
For the full list of settings and their values, see
10-
https://docs.djangoproject.com/en/1.10/ref/settings/
10+
https://docs.djangoproject.com/en/2.0/ref/settings/
1111
"""
1212

1313
import os
@@ -17,7 +17,7 @@
1717

1818

1919
# Quick-start development settings - unsuitable for production
20-
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
20+
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
2121

2222
# SECURITY WARNING: keep the secret key used in production secret!
2323
SECRET_KEY = 'd-uguc(o8$i@^ea_+m^tv^_tt7loyf6zf^o3%*ws#zs42_u#(&'
@@ -37,7 +37,7 @@
3737
'django.contrib.sessions',
3838
'django.contrib.messages',
3939
'django.contrib.staticfiles',
40-
'core',
40+
'core.apps.CoreConfig',
4141
]
4242

4343
MIDDLEWARE = [
@@ -73,12 +73,13 @@
7373

7474

7575
# Database
76-
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
76+
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
77+
7778

7879
DATABASES = {
7980
'default': {
8081
'ENGINE': 'sql_server.pyodbc',
81-
'NAME': 'docker2',
82+
'NAME': 'AdventureWorksDW2017',
8283
'USER': 'sa',
8384
'PASSWORD': 'Alaska2017',
8485
'HOST': 'db1.internal.prod.example.com',
@@ -91,7 +92,7 @@
9192

9293

9394
# Password validation
94-
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
95+
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
9596

9697
AUTH_PASSWORD_VALIDATORS = [
9798
{
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
"""SqlServerOnDocker URL Configuration
22
33
The `urlpatterns` list routes URLs to views. For more information please see:
4-
https://docs.djangoproject.com/en/1.10/topics/http/urls/
4+
https://docs.djangoproject.com/en/2.0/topics/http/urls/
55
Examples:
66
Function views
77
1. Add an import: from my_app import views
8-
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
99
Class-based views
1010
1. Add an import: from other_app.views import Home
11-
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
1212
Including another URLconf
13-
1. Import the include() function: from django.conf.urls import url, include
14-
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1515
"""
16-
from django.conf.urls import url
1716
from django.contrib import admin
17+
from django.urls import path
1818

1919
urlpatterns = [
20-
url(r'^admin/', admin.site.urls),
20+
path('admin/', admin.site.urls),
2121
]

samples/development-frameworks/SqlServerOnDocker/SqlServerOnDocker/wsgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
It exposes the WSGI callable as a module-level variable named ``application``.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
7+
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
88
"""
99

1010
import os

0 commit comments

Comments
 (0)