Skip to content

Commit bd8007f

Browse files
committed
database mongodb
1 parent 1a5975f commit bd8007f

File tree

16 files changed

+274
-3
lines changed

16 files changed

+274
-3
lines changed

auth/online1/crud/models.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from django.db import models
2+
from django.utils.timezone import now
3+
4+
# Define your models from here:
5+
6+
# class User(models.Model):
7+
# first_name = models.CharField(null=False,max_length=30, default='jitendra')
8+
# last_name = models.CharField(null=False,max_length=30, default='kumar')
9+
# dob = models.DateField(null=True)
10+
11+
# def __str__(self):
12+
# return self.first_name + " " + \
13+
# self.last_name
14+
# class Instructor(models.Model):
15+
# full_time = models.BooleanField(default=True)
16+
# total_learners = models.IntegerField()
17+
# def __str__(self):
18+
# return "First name :" +self.first_name + " ," + \
19+
# "Last name :" +self.last_name+ " ," + \
20+
# "Is full time :"+ str(self.full)

auth/online1/manage.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
import sys
3+
4+
if __name__ == "__main__":
5+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
6+
try:
7+
from django.core.management import execute_from_command_line
8+
except ImportError:
9+
try:
10+
import django
11+
except ImportError:
12+
raise ImportError(
13+
"Couldn't import Django. Are you sure it's installed and "
14+
"available on your PYTHONPATH environment variable? Did you "
15+
"forget to activate a virtual environment?"
16+
)
17+
raise
18+
execute_from_command_line(sys.argv)

auth/online1/read_courses.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Django specific settings
2+
import inspect
3+
import os
4+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
5+
from django.db import connection
6+
# Ensure settings are read
7+
from django.core.wsgi import get_wsgi_application
8+
application = get_wsgi_application()
9+
10+
from crud.models import *
11+
from datetime import date
12+
13+
14+
# Your code starts from here:

auth/online1/read_instructors.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Django specific settings
2+
import inspect
3+
import os
4+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
5+
from django.db import connection
6+
# Ensure settings are read
7+
from django.core.wsgi import get_wsgi_application
8+
application = get_wsgi_application()
9+
10+
from crud.models import *
11+
from datetime import date
12+
13+
14+
# Your code starts from here:

auth/online1/read_learners.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Django specific settings
2+
import inspect
3+
import os
4+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
5+
from django.db import connection
6+
# Ensure settings are read
7+
from django.core.wsgi import get_wsgi_application
8+
application = get_wsgi_application()
9+
10+
from crud.models import *
11+
from datetime import date
12+
13+
14+
# Your code starts from here:

auth/online1/settings.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# PostgreSQL
2+
# This is a sample settings.py file for a Django project using PostgreSQL
3+
# 'OPTIONS': {
4+
# 'context_processors': [
5+
6+
# 'django.template.context_processors.debug',
7+
# 'django.template.context_processors.request',
8+
# 'django.contrib.auth.context_processors.auth',
9+
# 'django.template.context_processors.media',
10+
# 'django.contrib.messages.context_processors.messages',
11+
# ],
12+
# },
13+
# },
14+
# ]
15+
#
16+
DATABASES = {
17+
'default': {
18+
'ENGINE': 'django.db.backends.postgresql_psycopg2',
19+
'NAME': 'postgres',
20+
'USER': 'postgres',
21+
'PASSWORD': '#Replace it with generated password#',
22+
'HOST': 'postgres',
23+
'PORT': '5432',
24+
25+
}
26+
27+
}
28+
# Static files (CSS, JavaScript, Images)
29+
# https://docs.djangoproject.com/en/3.0/howto/static-files/
30+
STATIC_URL = '/static/'
31+
# SECURITY WARNING: keep the secret key used in production secret!
32+
# SECURITY WARNING: don't run with debug turned on in production!
33+
DEBUG = True
34+
ALLOWED_HOSTS = ['*']
35+
# Application definition
36+
# SECURITY WARNING: keep the secret key used in production secret!
37+
# SECURITY WARNING: don't run with debug turned on in production!
38+
# SECURITY WARNING: don't run with debug turned on in production!
39+
# SECURITY WARNING: don't run with debug turned on in production!
40+
# SECURITY WARNING: don't run with debug turned on in production!
41+
42+
INSTALLED_APPS = (
43+
'crud',
44+
)
45+
46+
SECRET_KEY = 'SECRET KEY for this Django Project'

auth/online1/write.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Django specific settings
2+
import inspect
3+
import os
4+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
5+
from django.db import connection
6+
# Ensure settings are read
7+
from django.core.wsgi import get_wsgi_application
8+
application = get_wsgi_application()
9+
10+
from crud.models import *
11+
from datetime import date
12+
13+
14+
# Your code starts from here:

server/database/docker-compose.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,40 @@ services:
1111
volumes:
1212
- mongo_data:/data/db
1313

14+
#Postgres service
15+
postgres_db:
16+
container_name: postgres_container
17+
image: postgres:latest
18+
environment:
19+
POSTGRES_USER: postgres
20+
POSTGRES_PASSWORD: postgres
21+
POSTGRES_DB: postgres_db
22+
PGDATA: /var/lib/postgresql/data
23+
ports:
24+
- 5432:5432
25+
restart: always
26+
volumes:
27+
- postgres_data:/var/lib/postgresql/data
28+
healthcheck:
29+
test: ["CMD", "pg_isready"]
30+
interval: 10s
31+
timeout: 5s
32+
retries: 5
33+
start_period: 30s
34+
35+
1436
# Node api service
1537
api:
1638
image: nodeapp
1739
ports:
1840
- 3030:3030
1941
depends_on:
2042
- mongo_db
43+
- postgres_db
44+
45+
2146

2247
volumes:
2348
mongo_data: {}
49+
postgres_data: {}
50+

server/djangoapp/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
backend_url =your backend url
1+
backend_url =http://127.0.0.1:3030/
22
sentiment_analyzer_url=your code engine deployment url

server/djangoapp/admin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
# from django.contrib import admin
1+
from django.contrib import admin
22
# from .models import related models
3+
from .models import CarModel, CarMake
34

45

56
# Register your models here.
7+
admin.site.register(CarModel)
8+
admin.site.register(CarMake)
69

710
# CarModelInline class
811

0 commit comments

Comments
 (0)