diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..3a7d77a --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,21 @@ +{ + "_meta": { + "hash": { + "sha256": "34c67823d0895516cdc008b7a1e9cfbb2ac3da7fcb4b6c292c9e6fcbecc606b7" + }, + "pipfile-spec": 6, + "requires": { + "python_full_version": "3.10.11", + "python_version": "3.10" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": {}, + "develop": {} +} diff --git a/db-conf.toml b/db-conf.toml index 776a9d3..fb5760e 100644 --- a/db-conf.toml +++ b/db-conf.toml @@ -1,16 +1,16 @@ -[testdb] +[jtt_crm] # 方言 -dialect = 'postgresql' +dialect = 'oracle' # ip -host = '127.0.0.1' +host = '172.16.1.36' # 端口 -port = 5432 +port = 1521 # 用户名 -user = 'postgres' +user = 'jtt_crm' # 密码 -passwd = 'root@123' +passwd = 'jtt_crm' # 数据库 -database = 'postgres' +database = 'dbcenter' # 连接池大小 pool_size = 15 # 连接超时回收(秒) diff --git a/main.py b/main.py index b003b61..95dadeb 100644 --- a/main.py +++ b/main.py @@ -6,17 +6,9 @@ # @Project : futool-db-lite # @Desc : 数据库测试 from session.engine.dbengine import DatabaseEngine -from session.engine.dbengine import container if __name__ == '__main__': - db_engine = DatabaseEngine('testdb') - db_engine2 = DatabaseEngine('testdb') - print(db_engine.engine is db_engine2.engine) + db_engine = DatabaseEngine('jtt_crm') session_factory = db_engine.create_session_factory() - session_factory2 = db_engine2.create_session_factory() - print(session_factory is session_factory2) - # for i in range(100): - # # sess = session_factory.create_session() - # sess = session_factory.open_session() - # print(id(sess)) - print(container.engines, container.factory) + sess = session_factory.open_session() + print(sess.select_all('select * from JTXY_CREDIT_TASK')) diff --git a/requirements.txt b/requirements.txt index 30d3aac..28516c2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,10 @@ annotated-types==0.5.0 -cx-Oracle==8.3.0 +cffi==1.15.1 +cryptography==41.0.2 greenlet==2.0.2 +oracledb==1.3.1 psycopg2-binary==2.9.6 +pycparser==2.21 pydantic==2.0.2 pydantic_core==2.1.2 SQLAlchemy==2.0.7 diff --git a/session/engine/dbengine.py b/session/engine/dbengine.py index ad27f00..b7bcb37 100644 --- a/session/engine/dbengine.py +++ b/session/engine/dbengine.py @@ -52,7 +52,8 @@ class DatabaseEngine(object): """ DB_URL = { 'postgresql': 'postgresql+psycopg2://{0}:{1}@{2}:{3}/{4}', - 'oracle': 'oracle+cx_oracle://{0}:{1}@{2}:{3}/?service_name={4}' + # 使用thin客户端,不需要oracle client + 'oracle': 'oracle+oracledb://{0}:{1}@{2}:{3}/?service_name={4}' } # 连接池容器名称,具体看ObjContainer对象 attr = 'engines'