A Python library that enables you to harness the power of Django's ORM in standalone Python scripts.
Project description
standalorm
A Python library that enables you to harness the power of Django's ORM in standalone Python scripts.
Installation
$ pip install standalorm
Usage
Getting started with standalorm is quick and easy.
-
Create a Django app in your project's root directory:
$ standalorm startapp
-
Create your models in
app-directory/models.py
:from django.db import models # For demonstration purposes only. class ExampleModel(models.Model): exampleField = models.Field()
-
Make and apply your migrations:
$ standalorm makemigrations
$ standalorm migrate
-
Import the
orm_init()
function into your code and call it with the dunder variable__file__
as its sole argument:from standalorm import orm_init orm_init(__file__)
-
Finally, import your models:
# orm_init() must be imported AND called before this! from db import models # Replace "db" with the name of your Django app if necessary # Do stuff with your models here
That's it.
This example doesn't demonstrate the full extent of standalorm's capabilities. You'll have to see the documentation for that.
Database Support
standalorm supports Oracle, PostgreSQL, and SQLite databases. A SQLite database connection comes configured for you, and standalorm will use it by default if you don't add a different one yourself. More on adding database connections can be found in the documentation.
Additional Notes
standalorm is intended for people who are already familiar with Django's ORM; as such, the basics of how to use the ORM are outside the scope of both this README and standalorm's documentation. If you're looking to familiarize yourself with Django's ORM, see Django's own documentation, particularly the sections on models and making queries.
Documentation
standalorm's full documentation can be found at https://standalorm.readthedocs.io.
Attributions
standalorm is based on Dan Caron's Django ORM Standalone Template.
"Django" is a registered trademark of the Django Software Foundation, which does not endorse this software.
License
standalorm is released under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for standalorm-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f5bcea7ffb97c66d84723a6c177ced3e41b0d5f8fe9dd0252ec3c8bce673c74 |
|
MD5 | 7cb7e6df44585cf8721ad34e0e9c2f3d |
|
BLAKE2b-256 | 7624d0e9036879eb3b259817e15b5bec11d8685f0e11e0d531db0a86cf661be5 |