Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
flask-backend
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
retno sonjaya
flask-backend
Commits
2f609eef
Commit
2f609eef
authored
Aug 14, 2024
by
Beno Sons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.env DB
parent
29ad9f84
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
8 deletions
+13
-8
README.md
README.md
+6
-0
app/config.py
app/config.py
+1
-1
app/config_db.py
app/config_db.py
+6
-7
No files found.
README.md
View file @
2f609eef
...
@@ -17,6 +17,12 @@ PORT=8000
...
@@ -17,6 +17,12 @@ PORT=8000
-----------------------------
-----------------------------
SECRET_KEY=your-secret-key
SECRET_KEY=your-secret-key
DATABASE_URL=postgresql://postgres:khansia215758@30.10.20.102/BUILDER
DATABASE_URL=postgresql://postgres:khansia215758@30.10.20.102/BUILDER
DATABASE_NAME=BUILDER
DB_USERNAME=postgres
DB_PASSWORD=khansia215758
DB_HOST=30.10.20.102
DB_PORT=5432
DATABASE_SCHEMA=gen_application_31
JWT_SECRET_KEY=your-jwt-secret-key
JWT_SECRET_KEY=your-jwt-secret-key
FLASK_APP=run.py
FLASK_APP=run.py
FLASK_ENV=development
FLASK_ENV=development
...
...
app/config.py
View file @
2f609eef
...
@@ -6,7 +6,7 @@ load_dotenv()
...
@@ -6,7 +6,7 @@ load_dotenv()
class
Config
:
class
Config
:
SECRET_KEY
=
os
.
getenv
(
'SECRET_KEY'
,
'mysecretkey'
)
SECRET_KEY
=
os
.
getenv
(
'SECRET_KEY'
,
'mysecretkey'
)
SQLALCHEMY_DATABASE_URI
=
os
.
getenv
(
'DATABASE_URL'
,
'postgresql://user:password@localhost/dbname'
)
SQLALCHEMY_DATABASE_URI
=
f
"postgresql://{os.getenv('DB_USERNAME')}:{os.getenv('DB_PASSWORD')}@{os.getenv('DB_HOST')}:{os.getenv('DB_PORT')}/{os.getenv('DATABASE_NAME')}"
SCHEMA_NAME
=
os
.
getenv
(
'DATABASE_SCHEMA'
)
SCHEMA_NAME
=
os
.
getenv
(
'DATABASE_SCHEMA'
)
SQLALCHEMY_TRACK_MODIFICATIONS
=
False
SQLALCHEMY_TRACK_MODIFICATIONS
=
False
DEBUG
=
os
.
getenv
(
'FLASK_ENV'
)
==
'development'
DEBUG
=
os
.
getenv
(
'FLASK_ENV'
)
==
'development'
...
...
app/config_db.py
View file @
2f609eef
#!/usr/bin/python
#!/usr/bin/python
import
psycopg2
import
psycopg2
from
configparser
import
ConfigParser
from
configparser
import
ConfigParser
from
dotenv
import
load_dotenv
class
connection
():
class
connection
():
...
@@ -59,14 +59,13 @@ class connection():
...
@@ -59,14 +59,13 @@ class connection():
try
:
try
:
# read connection parameters
# read connection parameters
conn
=
psycopg2
.
connect
(
conn
=
psycopg2
.
connect
(
database
=
"BUILDER"
,
database
=
os
.
getenv
(
'DATABASE_NAME'
)
,
user
=
"postgres"
,
user
=
os
.
getenv
(
'DB_USERNAME'
)
,
password
=
"khansia215758"
,
password
=
os
.
getenv
(
'DB_PASSWORD'
)
,
host
=
"103.126.28.68"
,
host
=
os
.
getenv
(
'DB_HOST'
)
,
port
=
"8082"
port
=
os
.
getenv
(
'DB_PORT'
)
)
)
except
(
Exception
,
psycopg2
.
DatabaseError
)
as
error
:
except
(
Exception
,
psycopg2
.
DatabaseError
)
as
error
:
print
(
error
)
print
(
error
)
finally
:
finally
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment