Python代码:cx_oracle.databaseerror:ora-00933:SQL命令未正确结束

发布于 2025-01-25 12:25:16 字数 1468 浏览 2 评论 0原文

以下是我的代码,执行后显示上述错误:

import os
import cx_Oracle
import traceback
import sys
from tabulate import tabulate

cx_Oracle.init_oracle_client("C:/oracle/instantclient_21_3")

connection = cx_Oracle.connect(
 user="sxk7128",
 password="1234567890Qwertyuiop",
 dsn="acaddbprod-2.uta.edu:1523/pcse1p.data.uta.edu")

 cursor = connection.cursor()
 print("Successfully connected to Oracle Database")


ch=-1
while(ch != 0):
 try:
    print("\n\n-------------------------------------- MENU --------------------------------")
    print("1.  View all relations names                        2.  contents of each relation               
  3.  insert new customer data ")
    print("4.  View customer Data with ID                      5.  Delete customer phone 
   number              6.  Update Destination City  ")
    print("7.  Rollup operation with destination city,cost     8.  Cube operation with city & 
  sum of ticket cost ")
    print("9.  View Average buyer rating of transactions       10. Buy orders and Cities with 
   avg ticket cost above 10      11. Sort most used destination cities        0. EXIT   ")

     ch=int(input("\nEnter your choice: "))

     if ch==1:
        a=cursor.execute("select table_name from user_tables")
        print(tabulate(a))
    
     if ch==2:
        relationname=input("enter the relation name to see contents:   ")
        b=cursor.execute(f"select * from {relationname}")
        print(tabulate(b))

Below is my code and when executed it is showing above mentioned error:

import os
import cx_Oracle
import traceback
import sys
from tabulate import tabulate

cx_Oracle.init_oracle_client("C:/oracle/instantclient_21_3")

connection = cx_Oracle.connect(
 user="sxk7128",
 password="1234567890Qwertyuiop",
 dsn="acaddbprod-2.uta.edu:1523/pcse1p.data.uta.edu")

 cursor = connection.cursor()
 print("Successfully connected to Oracle Database")


ch=-1
while(ch != 0):
 try:
    print("\n\n-------------------------------------- MENU --------------------------------")
    print("1.  View all relations names                        2.  contents of each relation               
  3.  insert new customer data ")
    print("4.  View customer Data with ID                      5.  Delete customer phone 
   number              6.  Update Destination City  ")
    print("7.  Rollup operation with destination city,cost     8.  Cube operation with city & 
  sum of ticket cost ")
    print("9.  View Average buyer rating of transactions       10. Buy orders and Cities with 
   avg ticket cost above 10      11. Sort most used destination cities        0. EXIT   ")

     ch=int(input("\nEnter your choice: "))

     if ch==1:
        a=cursor.execute("select table_name from user_tables")
        print(tabulate(a))
    
     if ch==2:
        relationname=input("enter the relation name to see contents:   ")
        b=cursor.execute(f"select * from {relationname}")
        print(tabulate(b))

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

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

发布评论

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