Python使用 odbc、jdbc与 Object Relational Mapping (ORM)进行数据库开发
3)odbc接口
Connection modules for Microsoft SQL databases
Anaconda安装完成后已经安装了pyodbc驱动,可以使用下列命令查看安装情况
conda list pyodbc
4) jdbc接口
5) Object Relational Mapping (ORM)
Object-relational mappers (ORMs)
5)django框架
django安装:
conda install django
conda install django =1.9
conda install -c anaconda django (安装v1.11.3)
conda install -c conda-forge django (安装v1.11.4)
在conda当前目录下创建子目录
mkdir djangoTest
cd djangoTest
用django-admin创建工程
django-admin startproject mysite
cd mysite
用django-admin创建app
django-admin startapp myapp
进入mysite,运行manage.py启动Web服务器
python manage.py runserver
补充:如果django在某个运行环境中安装过,如何检查
conda info --envs
conda list
conda list django
6)PyCharmp配置
Run 》Edit Configurations》+(Add New Configuration)
然后配置Python的Interpreter:选择“Add Local”,再从运行环境目录中找到Python.exe
7)django 开发初始步骤
django-admin startproject xx1
python manage.py startapp xx2
python manage.py runserver
CTRL+C(退出server)
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser / python manage.py changepassword
8)django添加静态网页
在setting.py中添加: (当static和templates目录在网站根目录中,不再app目录中时)
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
在模板中添加:
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static "yy/xx.css" %}" />
9)django参考
try_django_19视频, try_django_19源码
DjangoTutorialForBeginners视频, DjangoTutorialForBeginners源码