用database configuration Assistant 引导创建数据库。
创建操作用户:
-- 别加双引号,否则,无法用 create user geovindu identified by 888888; create user geovin identified by 888888; grant connect,resource,dba to geovindu; grant connect,resource,dba to geovin; grant create session,create table,unlimited tablespace to geovindu; grant create session,create table,unlimited tablespace to geovin;
测试连接
创建表:
drop table IF EXISTS GEOVINDU.School; create table GEOVINDU.School --創建表 ( SchoolId char(5) NOT NULL, -- SchoolName varchar(500) NOT NULL, SchoolTelNo varchar(8) NULL, PRIMARY KEY (SchoolId) --#主鍵 ); --对表的说明 comment on table GEOVINDU.School is '学校表'; --对表中列的说明 comment on column GEOVINDU.School.SchoolId is 'ID'; comment on column GEOVINDU.School.SchoolName is '名称'; comment on column GEOVINDU.School.SchoolTelNo is '电话号码'; select * from GEOVINDU.School order by SchoolId;
# encoding: utf-8 # 版权所有 2024 ©涂聚文有限公司 # 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎 # 描述:python -m pip install oracledb # python -m pip install cx_Oracle --upgrade # Author : geovindu,Geovin Du 涂聚文. # IDE : PyCharm Community Edition 2024.3 python 3.11 # OS : windows 10 # Datetime : 2024/12/23 20:33 # User : geovindu # Product : PyCharm Community # Project : ictsimple # File : oracledemo.py # explain : 学习 import cx_Oracle class SchoolInfo(object): """ """ def __init__(self): """ """ self.__idno=None self.__schoolname=None self.__schooltel=None @property def idno(self): """ :return: """ return self.__idno @idno.setter def idno(self,no:str): """ :param no: :return: """ self.__idno=no @property def schoolname(self): """ :return: """ return self.__schoolname @schoolname.setter def schoolname(self,name:str): """ :param name: :return: """ self.__schoolname=name @property def schooltel(self): """ :return: """ return self.__schooltel @schooltel.setter def schooltel(self,tel:str): """ :param city: :return: """ self.__schooltel=tel # 连接到Oracle数据库 orcl.docker.internal connection = cx_Oracle.connect(user="GEOVINDU", password="777777", dsn="localhost/TechnologyGame") # 创建游标 cursor = connection.cursor() # 执行查询 GEOVINDU. cursor.execute("SELECT * FROM School order by SchoolId") # 获取查询结果 result = cursor.fetchall() dt=[] # 打印查询结果 for idno,name,tel in result: #print(idno,name,tel) info=SchoolInfo() info.idno=idno info.schoolname=name info.schooltel=tel dt.append(info) print("****************") for dd in dt: print(dd.idno,dd.schoolname,dd.schooltel)
标签:.__,return,create,GEOVINDU,idno,oracle,new,self From: https://www.cnblogs.com/geovindu/p/18625010