Python代码:cx_oracle.databaseerror:ora-00933:SQL命令未正确结束
以下是我的代码,执行后显示上述错误:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论