Chinaunix首页 | 论坛 | 博客
  • 博客访问: 33347
  • 博文数量: 23
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 235
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-23 15:00
文章分类

全部博文(23)

文章存档

2011年(1)

2009年(22)

我的朋友
最近访客

分类: Python/Ruby

2009-06-15 14:24:00

 

 


简单写了一个小脚本
import os
import sys
import cx_Oracle
from pprint import pprint
answer = raw_input("请启动oracle服务:Y/N?:" )
if (answer == 'N' or answer == 'n'):
     shili = raw_input("请输入你要启动的数据库实例:")
     print "oracleservice%s 服务正在启动..." % (shili)
     start = 'net start oracleservice%s' % (shili)
     os.system(start)
     print "服务启动成功"
else:
     print "服务已经启动"
answer_1 = raw_input("请启动oracle监听程序?Y/N?:")
if (answer_1 == 'N' or answer_1 == 'n'):
     start_1 = 'lsnrctl start'
     start_2 = 'lsnrctl status'
     os.system(start_1)
     os.system(start_2)
     print "正在监听"
else:
     print "服务已经启动"
#登录scott用户,做简单查询
db = cx_Oracle.connect('scott/oracle')
cursor = db.cursor()
cursor.execute('select * from emp')
pprint(cursor.fetchall())
阅读(721) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~