import file from view.py

23 views
Skip to first unread message

sum abiut

unread,
Mar 13, 2018, 9:07:10 PM3/13/18
to django...@googlegroups.com
I have a conf file containing the parameter of hostmane,db,usernam,pass, db

i want to import that file from view.py and use parameter from the conf file to connect to a db.

i did something this from appname.conf import but it doesn't seem to work, appreciate any assistance.

cheers

Etienne Robillard

unread,
Mar 14, 2018, 5:53:06 AM3/14/18
to sum abiut, django...@googlegroups.com

show us some code man :-)

Etienne

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y5Og0o5yb_e%3D6ggLjS%2BOtDyZFUoqe_9KYZLbC1w72g7MA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Etienne Robillard
tka...@yandex.com
https://www.isotopesoftware.ca/

Mahesh M J

unread,
Mar 14, 2018, 10:22:06 AM3/14/18
to django...@googlegroups.com
Hi,
You can try to create a Python module and write a parser there and set the variables. You can import that file in views.py and use it for getting the relevant values. Hope this helps.

Thanks,
Mahesh.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y5Og0o5yb_e%3D6ggLjS%2BOtDyZFUoqe_9KYZLbC1w72g7MA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
Mahesh M.J
Bioinformatics Consultant
Novartis Pharmaceuticals
1 Health Plaza, East Hanover
New Jersey-07039 

sum abiut

unread,
Mar 14, 2018, 5:34:16 PM3/14/18
to django...@googlegroups.com
Thanks,
i manage to resolve that by creating a function on the conf.py file which connect to the db, then call that function from view.py


conf.py

from sqlalchemy import*
def connect():
    engine=create_engine('mssql+pymssql://userbame:password@host /db')
    connection=engine.connect()
    return engine,connection

view.py
from userprofile.conf import *

engine,connection=connect()


On Wed, Mar 14, 2018 at 11:26 PM, Mahesh M J <amma...@gmail.com> wrote:
Hi,
You can try to create a Python module and write a parser there and set the variables. You can import that file in views.py and use it for getting the relevant values. Hope this helps.

Thanks,
Mahesh.

On Tue, Mar 13, 2018 at 21:06 sum abiut <sua...@gmail.com> wrote:
I have a conf file containing the parameter of hostmane,db,usernam,pass, db

i want to import that file from view.py and use parameter from the conf file to connect to a db.

i did something this from appname.conf import but it doesn't seem to work, appreciate any assistance.

cheers

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
--
Mahesh M.J
Bioinformatics Consultant
Novartis Pharmaceuticals

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages