注册
Dameng docker Jupyter notebook
技术分享/ 文章详情 /

Dameng docker Jupyter notebook

Dunkadunka 2024/12/27 303 0 0

目标

未安装数据库的windows使用notebook连接docker中的Dameng

Windows

pip install jupyter

安装dmPython

离线安装

  • 从已经安装了dameng的主机中获取dmpython
PS D:\doc\DM\Docker_notebook\dmPython> python setup.py install Traceback (most recent call last): File "D:\doc\DM\Docker_notebook\dmPython\setup.py", line 115, in <module> if CheckDmHome(path): ^^^^^^^^^^^^^^^^^ File "D:\doc\DM\Docker_notebook\dmPython\setup.py", line 58, in CheckDmHome file=open(str_pytemp,'w') ^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'd:\\doc\\DM\\Docker_notebook\\.venv\\Scripts\\Lib\\site-packages\\dpi.py'

在线安装

PS D:\doc\DM\Docker_notebook> pip install dmPython Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting dmPython Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e1/78/eb9f812c7d731ad30c213602dfecf5d2441ba39be1cf7ceb4d3bb8c77e9c/dmPython-2.5.8-cp311-cp311-win_amd64.whl (7.5 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.5/7.5 MB 9.7 MB/s eta 0:00:00 Installing collected packages: dmPython Successfully installed dmPython-2.5.8
  • 成功

测试

>>> import dmPython >>> conn = dmPython.connect('SYSDBA', 'SYSDBA', '192.168.0.193:5236') >>> dmPython.apilevel '2.0' >>> cursor = conn.cursor() >>> cursor.execute('select * from ALL_TABLES limit 1') <builtins.DmdbCursor on <dmPython.Connection to SYSDBA@192.168.0.193:5236>> >>> print(cursor.fetchall()) [('SYS', 'SYSOBJECTS', 'SYSTEM', None, 'SYSOBJECTS', 'VALID', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'ENABLED', None, None, 'NO', 'IOT', 'N', None, None, None, None, None, 'DISABLED', 'YES', 'NO', None, None, None, None, None, None, None, None, None, 'YES', None, 'DISABLED')]
  • 正常

安装SQLAlchemy

  • 从已经安装了dameng的主机中获取sqlalchemy2.0.0
cd .\sqlalchemy2.0.0\
python .\setup.py install
pip list

安装配置jupyter notebook 和 ipython-sql

pip install ipython-sql pip install jupyter

Docker 安装 DM

docker load -i dm8_20241022_x86_rh6_64_single.tar docker images

运行DM8

docker run -d \ -p 30236:5236 \ --restart=always \ --name=dm8_test \ --privileged=true \ -e LD_LIBRARY_PATH=/opt/dmdbms/bin \ -e PAGE_SIZE=16 \ -e EXTENT_SIZE=32 \ -e LOG_SIZE=256 \ -e UNICODE_FLAG=1 \ -e INSTANCE_NAME=dm8_test \ -v ./data:/opt/dmdbms/data \ dm8_single:dm8_20241022_rev244896_x86_rh6_64

测试Notebook

%load_ext sql %config SqlMagic.style = '_DEPRECATED_DEFAULT' %sql dm+dmPython://SYSDBA:SYSDBA001@localhost:30236 %sql select * from ALL_TABLES limit 1;

官方社区地址:https://eco.dameng.com

评论
后发表回复

作者

文章

阅读量

获赞

扫一扫
联系客服