django连接oracle

bigzhu posted @ Jul 02, 2007 06:16:00 PM in django , 10130 阅读

http://www.python.net/crew/atuining/cx_Oracle/下载适配器cx_Oracle

打开settings.py文件,配置oracle连接:

DATABASE_ENGINE = 'oracle' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = 'bill' # Or path to database file if using sqlite3.
DATABASE_USER = 'acct' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '1521' # Set to empty string for default. Not used with sqlite3.

DATABASE_ENGINE 填入数据库驱动,这里自然填入oracle

DATABASE_NAME 填入sid,可以查看本机的tnsnames.ora是如何配置的

DATABASE_USER 数据库用户

DATABASE_PASSWORD 用户密码

DATABASE_HOST 直接填入ip地址就可以

DATABASE_PORT oracle服务的端口号

配置完毕后,保存,开始测试:

进入django的project目录

python manage.py shell

进入使用了对应settings的命令行.

输入:

>>> from django.db import connection
>>> cursor = connection.cursor()

没有任何报错就说明成功了.


jnanabhumiap.in 说:
Jan 10, 2024 11:00:55 AM

Among many other things, JNANABHUMI AP offers the most recent information on education. The primary idea or goal of this website has been to offer comprehensive resources with information on any subject that can be accessed online. To make sure that every reader finds out what they should know about the subject they are interested in and jnanabhumiap.in links to our content.Jnanabhumi AP is a startup founded by enthusiastic bloggers and webmasters who are driven to produce interesting, factual, and well-written content. We are similar to an online community where you can find a variety of resources, information, and topics about newsworthy events or daily occurrences.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter