python中的甲骨文桌问题

发布于 2025-01-25 04:01:50 字数 945 浏览 3 评论 0原文

我正在尝试执行以下代码,但有错误。任何人都可以帮忙吗?

data1=[218031839]
if not data1:
    print("Nothing")
else:
    cur1 = con_m.cursor()**strong text**             
    query_3_1a='''create table tmp_account2 as '''
    query_3_1c='select ban from account where ban`enter code here` in ('
    query_3_1b = ''`enter code here`
    ban_cnt3 = len(data1)
    print("ban_count",ban_cnt3)
    j=0
    for i in data1: 
        j=j+1
        if j < ban_cnt3:
            query_3_1b = query_3_1b+ format(i) + ' ,'
        else:
            query_3_1b = query_3_1b+ format(i) + ')'

    
    

    query_3_1 = query_3_1a+query_3_1c + query_3_1b
    cur1.execute(query_3_1)
    print("table created") 
    #h1=cur1.fetchall()
    #print("hhhh",h1)
    
    
for tmp_account2 in cur1:
    print(tmp_account2)

错误:对于Cur1中的TMP_ACCOUNT2: cx_oracle.interfaceError:不是查询

意味着该表无法使用Python中的DB连接创建,但是如果此查询在SQL Developer中执行,则可以正常工作。

I am trying to execute the below code but got an error. Can anyone please help.

data1=[218031839]
if not data1:
    print("Nothing")
else:
    cur1 = con_m.cursor()**strong text**             
    query_3_1a='''create table tmp_account2 as '''
    query_3_1c='select ban from account where ban`enter code here` in ('
    query_3_1b = ''`enter code here`
    ban_cnt3 = len(data1)
    print("ban_count",ban_cnt3)
    j=0
    for i in data1: 
        j=j+1
        if j < ban_cnt3:
            query_3_1b = query_3_1b+ format(i) + ' ,'
        else:
            query_3_1b = query_3_1b+ format(i) + ')'

    
    

    query_3_1 = query_3_1a+query_3_1c + query_3_1b
    cur1.execute(query_3_1)
    print("table created") 
    #h1=cur1.fetchall()
    #print("hhhh",h1)
    
    
for tmp_account2 in cur1:
    print(tmp_account2)

Error: for tmp_account2 in cur1:
cx_Oracle.InterfaceError: not a query

Means the table is not able to create using db connection in python but if this query gets executed in SQl developer then it's working fine.

.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文