How to import Django DB operations out of Django projects
2024-09-04 14:43:23
i am not familiar with DB opertions. usually i stroe data to txt and other formats. as DB is more and more popular, i want to try it too.
i have some knowledge about Django. the DB opertions in Django is very easy than the DB source code. so i decided to reuse the Django DB operations out of Django projects.
it is very useful for small progress.
import os,sys
sys.path.append('Django project path')
os.environ['DJANGO_SETTINGS_MODULE']='settings'
from .views import viewClasses
import django
django.setup()
All right, we can reuse the Django DB operations for the 'viewClasses' now.
it is practical for basic DB operations like Add / Delete / Update / Retrieve
Hope it can help you.
最新文章
- ASP.NET MVC Module
- asp.net 验证控件
- getchar的利用
- Js-字符串截取substring,分割split,指标indexOf,拼接John
- OS10.11系统下 安装cocoapods 以及 安装cocoapods-xcode-plugin-master插件来加载三方框架
- 快学Java NIO 续篇
- for语句
- css三角形的实现
- 深入理解Javascript
- Junit4 架构设计系列(2): Runner.run()与Statement
- java_IO流小结
- Spring4 事务管理
- 前端的UI设计与交互之布局篇
- Dynamics CRM2016 Web API之Retrieve Multiple
- echart四川地图
- xshell 禁用铃声 提示音
- 【bzoj4765】 普通计算姬
- 170407、java基于nio工作方式的socket通信
- Linux:redhat6.5使用yum时提示需要注册问题解决方案
- ZC__问题