Python中文
首页
教程
问答
标签
搜索
登录
注册
使用JupyterLab SQL Magic throw编程错误连接到DB2z:“CURRENT”无效
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我尝试设置一个Jupyter笔记本,使用sqlmagic(%and%%表示法)访问ibmdb2z数据库。在</p> <p>我跟随本教程安装DB2 SQLAlchemy驱动程序: <a href="https://blog.4loeser.net/2016/11/sql-magic-in-notebooks-in-ibm-data.html" rel="nofollow noreferrer">https://blog.4loeser.net/2016/11/sql-magic-in-notebooks-in-ibm-data.html</a></p> <p>现在我在Jupyter实验室的代码如下:</p> <pre><code>!pip install --user ipython-sql !pip install --user ibm_db !pip install --user ibm_db_sa import getpass import ibm_db import ibm_db_sa import sqlalchemy user = input("User: ") passw = getpass.getpass("Passwort: ") # loads the SQL magic extensions %load_ext sql %sql db2+ibm_db://$user:$passw@xxx.xxx.xx:55555/XXX </code></pre> <p>但会导致以下错误:</p> ^{pr2}$ <p>我可以排除用户名密码或驱动程序中的错误,因为它是使用pandas works实现的:</p> <pre><code>import pandas as pd from sqlalchemy.engine import create_engine engine = create_engine("db2+ibm_db://"+user+":"+passw+"@xxx.xxx.xx:55555/XXX") #Read Data query into a DataFrame df = pd.read_sql("""select * from XXX.XXXXX limit 1""", engine) df.head() </code></pre> <p>关键字CURRENT似乎有一个问题,但是我无法理解pandas和sqlmagic之间的区别。在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>我建议使用ibm_db和ibm_db_dbi包装器。请参阅我的db2文章以获得更好的解释</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
文本导入时标题行中的特殊字符
8 回答
文本小部件:在没有输入时更新并在循环后保持空闲
9 回答
文本小部件tkin
9 回答
文本小部件tkinter中的标签更改或文本外观更改是否有撤消功能?
10 回答
文本小部件tkinter复制图像选项
1 回答
文本小部件上的Python Tkinter ttk滚动条未缩放
10 回答
文本小部件上的滚动条可能需要根据制表符ord显示前进行滚动
2 回答
文本小部件不显示lis中的内容
1 回答
文本小部件不显示Unicode字符
3 回答
文本小部件中写入的行间距
4 回答
文本小部件中的文本作为变量
5 回答
文本小部件中的滚动条仅显示在底部
8 回答
文本小部件中的选项卡键空间计数
3 回答
文本小部件作为Lis
4 回答
文本小部件在主框架中扩展列宽
5 回答
文本小部件未使用删除功能清除
8 回答
文本小部件滚动动画(Tkinter、Python)
7 回答
文本居中。格式正确吗?
4 回答
文本差分算法
4 回答
文本已知时音频文件中的单词索引
3 回答