Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python在临时SQL表上创建和运行查询_Python_Sql_Oracle_Temporary - Fatal编程技术网

使用Python在临时SQL表上创建和运行查询

使用Python在临时SQL表上创建和运行查询,python,sql,oracle,temporary,Python,Sql,Oracle,Temporary,我试图使用Python创建临时sql表(oracle),然后我想在这些临时表上运行查询,并将输出转换为数据帧 我这样创建了一个临时表: curs.execute("""CREATE GLOBAL TEMPORARY TABLE temp_customer ON COMMIT PRESERVE ROWS AS (select c_entity_id id_customer, c_gender gender from CUSTOMERS)""") 然后我想查询它并将其转换为数据帧:

我试图使用Python创建临时sql表(oracle),然后我想在这些临时表上运行查询,并将输出转换为数据帧

我这样创建了一个临时表:

curs.execute("""CREATE GLOBAL TEMPORARY TABLE temp_customer
ON COMMIT PRESERVE ROWS AS
(select
    c_entity_id id_customer,
    c_gender gender
from CUSTOMERS)""")
然后我想查询它并将其转换为数据帧:

query_test="""select * from temp_customer"""

test_df = pd.read_sql_query(query_test, con)

脚本一直在运行,但什么也没发生。

为什么要在运行时创建临时表?这通常没有意义——当您创建所有永久表时,应该在安装时创建临时表。在运行时创建临时表在多用户应用程序中通常不起作用——如果其他会话想要创建相同的表,它将得到一个错误。如果其他会话想要删除
temp\u customer
表,它将成功并导致会话失败。