Thursday, July 2, 2015

Re: Django model for non web applications

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCAAGBQJVldwhAAoJEC0ft5FqUuEh9yMQALNXdJ0FpMDEV/A6MRoFhyE3
ygMgv802eei5i1cORXo0tC1LeDjhWXXXy9nV3qsmxL5iiiA8Q21/PyzKc37Dln5Y
cihfxt+wi1zEGV4ZHFUXTeLAT0wj8Et6mPyzKbYQHMKKP0WuVDYXtTeu21t1koWu
MnSnv9UODWF0FfN1DCPnxFQHbfeXsZ8Vn6+XBC5kYiJ56xyOmTphHXBx3mWVPNrN
QoDd58r8i2P8M8paSAKf8WJoR4Bp/WfnuxuU7+pO/RWuGK/s9hbMs08akw7I7pb9
M2hiZH+Q5ggjDROp+j+lJRKiPKPRGUfNm5zMA0z3Bl3TVW9uEhI77n3RXH+GnVtM
cZqtGD/7ejStMJOt8UuqHaCkwpX9BtGR4SroxavVeQlSLa8+Ci0OE9nfnCzB7Bp8
Goi0AhKYVvrJGwitxLl3ZDFoKBPHflGGWRspZFComoq35BGxVanu+fAlp3vMo32I
zRdNILgaA7vd8g8zFZbxatQhl4NIVNt/ngatvResam4Fc3lyXGoq+78VKtQw4cTl
VO+JomJfUtCme+94WHA55+Nx/BT9NJHI8pNt3+o/VieYiS0k3rDN5nfk3irvc6Ke
OPu5J3MV6Uymhy7baCEhwbUED76/R3qOC+Q6qNlBDJQDbQZpMgURQpQ8Px1honZp
OEvNxvMayUifrI5f1cj3
=k1wD
-----END PGP SIGNATURE-----
On 07/02/2015 05:49 PM, Russell Keith-Magee wrote:
>
> On Thu, Jul 2, 2015 at 12:50 AM, Jeff Fritz <jefffritz@gmail.com
> <mailto:jefffritz@gmail.com>> 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+unsubscribe@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.

No comments:

Post a Comment