Re: Django model for non web applications

2015-07-03 Thread Carl Meyer
On 07/03/2015 07:46 AM, Vernon D. Cole wrote:
> Jeff:
>I think that Russell's answer might be more appropriate for your use
> case than Carl's.  django.setup() calls settings.configure(), but also
> tries to pull in other application modules, which you might not want.

No, `settings.configure()` and `django.setup()` are not alternatives.
They are _both_ needed for Jeff's use case (depending on how he wants to
handle settings). `settings.configure()` is one option for settings;
`django.setup()` is required no matter what (since Django 1.7).

Settings can be handled either via the usual Python settings module, in
which case the DJANGO_SETTINGS_MODULE env var needs to be set to the
import path to this module, or they can be handled by calling
`settings.configure()` with a dict of the desired settings.

One of those two things needs to be done before calling
`django.setup()`. `setup()` does not "call settings.configure()" - it
loads settings, which requires either that `settings.configure()` has
already been called, or that DJANGO_SETTINGS_MODULE is set.

And yes, `django.setup()` also loads installed applications. Since
Django 1.7, this is required in order to use the ORM (which is the core
of Jeff's use case).

Carl

> 
> 
> On Thursday, July 2, 2015 at 6:50:20 PM UTC-6, Carl Meyer wrote:
> 
> On 07/02/2015 05:49 PM, Russell Keith-Magee wrote:
> >
> > On Thu, Jul 2, 2015 at 12:50 AM, Jeff Fritz  
> > > wrote:
> >
> > I'm fairly new to Django and making my way through the tutorial.
> >
> > Knowing what I've learned so far, I'd like to explore using
> > django.db.models.Model in a non-web application. I'd like to take
> > the entire model layer and use it for database access in a
> > standalone, multithreaded python 3.4 application. It is not a web
> > application. I would like to be able to take advantage of the
> > migration capabilities in manage.py.
> >
> > Questions:
> >
> > 1. Is it as simple as adding `from djanago.db import models`?
> Would
> > this bring in any unnecessary django packages/modules,
> considering I
> > will not be developing a web application, not using views,
> > templating, etc?
> >
> >
> > It's *almost* this simple - you will also need to configure your
> Django
> > environment before you start making database calls. If you're
> looking to
> > do this in a *completely* "non-web" way, this probably means a
> call to
> > settings.configure(); details here:
> >
> > https://docs.djangoproject.com/en/1.8/topics/settings/
> 
> 
> Don't forget that in Django 1.7+ you also need to call django.setup()
> yourself, if using Django outside the context of a WSGI server or
> management command:
> https://docs.djangoproject.com/en/1.8/ref/applications/#django.setup
> 
> 
> Carl
> 
> >  
> >
> > 2. Is the django model layer thread safe? Specifically, when
> using
> > sqlite3 as a back end?
> >
> >
> > It should be - after all, web servers are frequently multi-threaded.
> > SQLite3's performance under multithreading, however, might leave
> > something to be desired.
> >  
> >
> > 3. Are there other clean ORM/database model layer
> > frameworks/packages that I should consider for python 3.4?
> >
> >  
> > The other obvious candidate would be SQLAlchemy; it's a perfectly
> fine
> > ORM - without any of the other web framework overhead. It's a lot
> more
> > like a "SQL building toolkit" than Django's ORM - whether this is
> a good
> > or bad thing depends on your own preferences and use case.
> >
> > Yours,
> > Russ Magee %-)
> 
> -- 
> 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+unsubscr...@googlegroups.com
> .
> To post to this group, send email to django-users@googlegroups.com
> .
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/05d20585-bf6e-4c1f-8014-2ea19e2d7aa0%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.

-- 
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-

Re: Django model for non web applications

2015-07-03 Thread Vernon D. Cole
Jeff:
   I think that Russell's answer might be more appropriate for your use 
case than Carl's.  django.setup() calls settings.configure(), but also 
tries to pull in other application modules, which you might not want.


On Thursday, July 2, 2015 at 6:50:20 PM UTC-6, Carl Meyer wrote:
>
> On 07/02/2015 05:49 PM, Russell Keith-Magee wrote: 
> > 
> > On Thu, Jul 2, 2015 at 12:50 AM, Jeff Fritz   
> > > wrote: 
> > 
> > I'm fairly new to Django and making my way through the tutorial. 
> > 
> > Knowing what I've learned so far, I'd like to explore using 
> > django.db.models.Model in a non-web application. I'd like to take 
> > the entire model layer and use it for database access in a 
> > standalone, multithreaded python 3.4 application. It is not a web 
> > application. I would like to be able to take advantage of the 
> > migration capabilities in manage.py. 
> > 
> > Questions: 
> > 
> > 1. Is it as simple as adding `from djanago.db import models`? Would 
> > this bring in any unnecessary django packages/modules, considering I 
> > will not be developing a web application, not using views, 
> > templating, etc? 
> > 
> > 
> > It's *almost* this simple - you will also need to configure your Django 
> > environment before you start making database calls. If you're looking to 
> > do this in a *completely* "non-web" way, this probably means a call to 
> > settings.configure(); details here: 
> > 
> > https://docs.djangoproject.com/en/1.8/topics/settings/ 
>
> Don't forget that in Django 1.7+ you also need to call django.setup() 
> yourself, if using Django outside the context of a WSGI server or 
> management command: 
> https://docs.djangoproject.com/en/1.8/ref/applications/#django.setup 
>
> Carl 
>
> >   
> > 
> > 2. Is the django model layer thread safe? Specifically, when using 
> > sqlite3 as a back end? 
> > 
> > 
> > It should be - after all, web servers are frequently multi-threaded. 
> > SQLite3's performance under multithreading, however, might leave 
> > something to be desired. 
> >   
> > 
> > 3. Are there other clean ORM/database model layer 
> > frameworks/packages that I should consider for python 3.4? 
> > 
> >   
> > The other obvious candidate would be SQLAlchemy; it's a perfectly fine 
> > ORM - without any of the other web framework overhead. It's a lot more 
> > like a "SQL building toolkit" than Django's ORM - whether this is a good 
> > or bad thing depends on your own preferences and use case. 
> > 
> > Yours, 
> > Russ Magee %-) 
>
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/05d20585-bf6e-4c1f-8014-2ea19e2d7aa0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django model for non web applications

2015-07-02 Thread Carl Meyer
On 07/02/2015 05:49 PM, Russell Keith-Magee wrote:
> 
> On Thu, Jul 2, 2015 at 12:50 AM, Jeff Fritz  > wrote:
> 
> I'm fairly new to Django and making my way through the tutorial.
> 
> Knowing what I've learned so far, I'd like to explore using
> django.db.models.Model in a non-web application. I'd like to take
> the entire model layer and use it for database access in a
> standalone, multithreaded python 3.4 application. It is not a web
> application. I would like to be able to take advantage of the
> migration capabilities in manage.py.
> 
> Questions:
> 
> 1. Is it as simple as adding `from djanago.db import models`? Would
> this bring in any unnecessary django packages/modules, considering I
> will not be developing a web application, not using views,
> templating, etc?
> 
> 
> It's *almost* this simple - you will also need to configure your Django
> environment before you start making database calls. If you're looking to
> do this in a *completely* "non-web" way, this probably means a call to
> settings.configure(); details here:
> 
> https://docs.djangoproject.com/en/1.8/topics/settings/

Don't forget that in Django 1.7+ you also need to call django.setup()
yourself, if using Django outside the context of a WSGI server or
management command:
https://docs.djangoproject.com/en/1.8/ref/applications/#django.setup

Carl

>  
> 
> 2. Is the django model layer thread safe? Specifically, when using
> sqlite3 as a back end?
> 
> 
> It should be - after all, web servers are frequently multi-threaded.
> SQLite3's performance under multithreading, however, might leave
> something to be desired.
>  
> 
> 3. Are there other clean ORM/database model layer
> frameworks/packages that I should consider for python 3.4?
> 
>  
> The other obvious candidate would be SQLAlchemy; it's a perfectly fine
> ORM - without any of the other web framework overhead. It's a lot more
> like a "SQL building toolkit" than Django's ORM - whether this is a good
> or bad thing depends on your own preferences and use case.
> 
> Yours,
> Russ Magee %-)

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5595DC21.5060600%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


Re: Django model for non web applications

2015-07-02 Thread Russell Keith-Magee
On Thu, Jul 2, 2015 at 12:50 AM, Jeff Fritz  wrote:

> I'm fairly new to Django and making my way through the tutorial.
>
> Knowing what I've learned so far, I'd like to explore using
> django.db.models.Model in a non-web application. I'd like to take the
> entire model layer and use it for database access in a standalone,
> multithreaded python 3.4 application. It is not a web application. I would
> like to be able to take advantage of the migration capabilities in
> manage.py.
>
> Questions:
>
> 1. Is it as simple as adding `from djanago.db import models`? Would this
> bring in any unnecessary django packages/modules, considering I will not be
> developing a web application, not using views, templating, etc?
>

It's *almost* this simple - you will also need to configure your Django
environment before you start making database calls. If you're looking to do
this in a *completely* "non-web" way, this probably means a call to
settings.configure(); details here:

https://docs.djangoproject.com/en/1.8/topics/settings/


> 2. Is the django model layer thread safe? Specifically, when using sqlite3
> as a back end?
>

It should be - after all, web servers are frequently multi-threaded.
SQLite3's performance under multithreading, however, might leave something
to be desired.


> 3. Are there other clean ORM/database model layer frameworks/packages that
> I should consider for python 3.4?
>

The other obvious candidate would be SQLAlchemy; it's a perfectly fine ORM
- without any of the other web framework overhead. It's a lot more like a
"SQL building toolkit" than Django's ORM - whether this is a good or bad
thing depends on your own preferences and use case.

Yours,
Russ Magee %-)

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJxq848qKXu3GT6kpwLzvd1-V-a6eTjw%2BByY-XATTk1DiKVpGQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django model for non web applications

2015-07-01 Thread Jeff Fritz
I'm fairly new to Django and making my way through the tutorial.

Knowing what I've learned so far, I'd like to explore using 
django.db.models.Model in a non-web application. I'd like to take the 
entire model layer and use it for database access in a standalone, 
multithreaded python 3.4 application. It is not a web application. I would 
like to be able to take advantage of the migration capabilities in 
manage.py.

Questions:

1. Is it as simple as adding `from djanago.db import models`? Would this 
bring in any unnecessary django packages/modules, considering I will not be 
developing a web application, not using views, templating, etc?

2. Is the django model layer thread safe? Specifically, when using sqlite3 
as a back end?

3. Are there other clean ORM/database model layer frameworks/packages that 
I should consider for python 3.4?

Thanks very much for any assistance,
Jeff

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7609b56f-1452-43d0-86c4-f6eab427e0dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.