Comments (3)
Possibly naive question: wondering if passing the connection info from outside the wrapper object is the way to go, especially if that information is just getting picked up from env variables or an external file. If the following env variables are already defined,
PGHOST=recordexpungpdx_db
PGUSER=docker
PGPORT=5432
PGDATABASE=record_expunge
then you can get the connection object with
import psycopg2
conn = psycopg2.connect(“”)
cur = conn.cursor()
and no extra arguments. Or else the values could be provided inside the Database wrapper code , e.g.
conn = pyscopg2.connect("dbname=record_expunge user=docker port=5432 host=recordexpungpdx_db")
cur = conn.cursor()
Is there a reason not to use these approaches?
from recordexpungpdx.
@wittejm this is a good question about separation of concerns: we need to get the credentials from the environment somewhere, so what part of the code should be responsible for doing that?
AFAIK Erik is currently working on this so I will defer to him for the actual implementation.
But my preference is to use your second approach and pass the credentials in. Environment variables are global variables. If we access them in multiple places in our code it can be difficult to draw a clear boundary between our app and its environment. The best practice here is to only access environment variables in one place, and create one or more configuration objects to pass that data around in our code.
from recordexpungpdx.
closing; Database connectivity was added some time ago.
from recordexpungpdx.
Related Issues (20)
- Paperwork printouts sometimes do not record checked boxes HOT 1
- Bounding box on cases in expanded analysis section HOT 4
- Create soft requirments for FillForms HOT 5
- Provide alternative search summary display HOT 6
- Create feature to log out of OECI credentials
- Create a section at the end of the Manual where we can post Form links
- Create new Eligibility types: "Eligible but on case with [Ineligible/Future Eligible] charge" HOT 14
- Add new Partners to the landing page HOT 5
- Add Arrest Date information to all expungement forms HOT 2
- Remove `#paybalances` links HOT 1
- Typo in "manual" page HOT 1
- Felony reduced to misdemeanor disambiguation
- Clackamas County HOT 4
- Implementing an "Expanded View" HOT 1
- NEW FORMS HOT 13
- NEW FORM PART 2 requests HOT 1
- Fix time analyzer tests HOT 4
- Makefile, Docker Compose, eslint HOT 5
- Broken deploy to staging
- Generate Paperwork button bug HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recordexpungpdx.