mirror of
https://github.com/ilri/dspace-statistics-api.git
synced 2024-11-29 01:18:19 +01:00
Alan Orth
c027f01b48
This follows guidance from several well-known Python best practices guides. Basically, the idea is create a package for the application that is comprised of several re-usable modules. See: https://docs.python-guide.org/writing/structure/ See: https://realpython.com/python-application-layouts/
13 lines
440 B
Python
13 lines
440 B
Python
from .config import DATABASE_NAME
|
|
from .config import DATABASE_USER
|
|
from .config import DATABASE_PASS
|
|
from .config import DATABASE_HOST
|
|
import psycopg2, psycopg2.extras
|
|
|
|
def database_connection():
|
|
connection = psycopg2.connect("dbname={} user={} password={} host='{}'".format(DATABASE_NAME, DATABASE_USER, DATABASE_PASS, DATABASE_HOST), cursor_factory=psycopg2.extras.DictCursor)
|
|
|
|
return connection
|
|
|
|
# vim: set sw=4 ts=4 expandtab:
|