What about if you want to use an ORM (Object-Relational Mapping) in your Python project ?. There is some alternatives online, but, if you're a Django Framework developer as me and you're used to the Django ORM, you would like to save time and use your skills.
How can I use it on my Non-Django projects ?
Now You have a file structures with the minimum configuration to start a Python project using Django ORM.
- Full use of Django ORM.
- Django >= 1.5
I also add a requirements.txt file, to use it run:
sudo pip install -r requirements.txt
├── app.py
├── generate_secret_key.py
├── manage.py
├── models
│ ├── models.py
├── requirements.txt
└── settings.py
- Generate a secret key running generate_secret_key.py, for example:
$ python generate_secret_key.py
7h&9l-81f9olfj_%ba#v5kh#e_1go$g*nw4#8#h&0#it6ak%_i
- Then copy the output string and asign it to the SECRET_KEY variable in settings.py
SECRET_KEY = "7h&9l-81f9olfj_%ba#v5kh#e_1go$g*nw4#8#h&0#it6ak%_i"
- Have Fun ! :)
- app.py: Write your app code here
- models/models.py: Write your models according to Django ORM specs. See django docs form more details.
- settings.py: You have to set the DBMS (MySQL, SQLite,...) you'll use and the secret key