List Info

Thread: use Django's database layer for a regular python program?




use Django's database layer for a regular python program?
country flaguser name
United States
2007-06-27 06:09:07
I'm currently developing a desktop application, not a web
application.
But I want to use django's models to store and retrieve data
in
Database. Is it possible? How should I do it?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: use Django's database layer for a regular python program?
country flaguser name
United States
2007-06-27 09:47:05
It's currently being done for a server application, I don't
see why it
couldn't be used for a desktop application as well?

Check out 
http://www.silverstripesoftware.com/blog/archives/51
and
http://code.google.
com/p/evennia/

The first is a desktop application that uses Django, I'm
just not sure
if it's using the database backend or not.   The second is a
MUD
server that uses Django for data storage as well as the web
services
for MUD management.

It should be as simple as creating a new project and
ignoring the urls/
views part of the code, and just importing the models as
normal.

HTH,

Michael

On Jun 27, 7:09 am, ahlongxp <ahlon...gmail.com> wrote:
> I'm currently developing a desktop application, not a
web application.
> But I want to use django's models to store and retrieve
data in
> Database. Is it possible? How should I do it?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: use Django's database layer for a regular python program?
country flaguser name
Hungary
2007-06-27 09:53:12
I worked on a console application which uses django to do
some  
database related tasks.
I started my code with these lines:

---

#!/usr/bin/env python
import sys
sys.path.append('/Library/Frameworks/Python.framework/Versio
ns/2.4/ 
lib/python2.4/site-packages/django')
sys.path.append('/path/to/the/application/directory/')

import os
os.environ['DJANGO_SETTINGS_MODULE'] =
'applicationname.settings'

---

 From this point you can continue by importing the
neccessary  
libraries and writing your code.

Maybe there is a better way of doing it but works
perfeclty.

---
Roodie




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: use Django's database layer for a regular python program?
country flaguser name
United States
2007-06-27 10:07:01
On Wed, Jun 27, 2007 at 04:53:12PM +0200, Roodie wrote:
> 
> I worked on a console application which uses django to
do some  
> database related tasks.
> I started my code with these lines:
> 
> ---
> 
> #!/usr/bin/env python
> import sys
>
sys.path.append('/Library/Frameworks/Python.framework/Versio
ns/2.4/ 
> lib/python2.4/site-packages/django')
> sys.path.append('/path/to/the/application/directory/')
> 
> import os
> os.environ['DJANGO_SETTINGS_MODULE'] =
'applicationname.settings'
> 
> ---
> 
>  From this point you can continue by importing the
neccessary  
> libraries and writing your code.
> 
> Maybe there is a better way of doing it but works
perfeclty.

Have a look at django.conf.settings.configure:

------------------------------------------------------------
--------------------
from django.conf import settings
settings.configure(
  INSTALLED_APPS = ( 'myappcontainingmodels', ),
  DEBUG = False
)
------------------------------------------------------------
--------------------

See:

http:/
/www.djangoproject.com/documentation/settings/#using-setting
s-without-setting-django-settings-module

-Forest
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )