GitHub B站UP主:sBobHuang

oracle数据库学习

centos可以改为Red Hat进行rpm安装,也可以下载zip安装

如果遇到错误,这是由于我使用的不是oracle Linux导致,强制跳过gpg检查即可

请使用

yum localinstall -y '/root/Downloads/oracle-database-ee-19c-1.0-1.x86_64.rpm'  --nogpgcheck

服务器内存太小了,最后还是去搞了台win的服务器,其实就是需要本地有这些lib的,否则找不到,还学了一下如何ln -s软连接

如果你要用python去查询可以用这个方法,所以其实只是需要这几个包而已

python可以用 cx_Oracle连接

import cx_Oracle
from sqlalchemy import create_engine

class OracleDB:
    def __init__(self):
        self.username='scott'
        self.password='tiger'
        self.hostname='139.196.213.70'
        self.port='1521'
        self.engine=None
        self.conn=None
        self.rconn=None

    def connect(self):
        try:
            self.engine = create_engine('oracle://scott:tiger@139.196.213.70:1521/orcl')
            self.conn = self.engine.connect()
            self.rconn = self.engine.raw_connection()
        except cx_Oracle.DatabaseError as e:
            self.engine=None
            print(e)
            exit(1)

    def select(self):
        res = self.conn.execute("select * from emp")
        payload = []
        content = {}
        for result in res:
            content = {'ename': result[0], 'job':result[1]}
            payload.append(content)
            content = {}
        return payload
View Code

 

posted @ 2019-06-16 21:57  暴力都不会的蒟蒻  阅读(...)  评论(... 编辑 收藏
TOJ