Get temporary table from SQL Server with SQLAlchemy

Viewed 33

in Python 3 sqlalchemy I do the following:

from sqlalchemy import create_engine
engine = create_engine(odbc_string)
with engine.begin() as conn:
    conn.execute("""exec my_database..my_procedure;""")
    cursor = conn.execute("""select * from #result;""")
_df = cursor.fetchall()

The procedure "my_procedure" does the following:

CREATE PROCEDURE my_procedure
    -- Add the parameters for the stored procedure here
    @mean int = 0, 
    @std int = 1
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    SELECT @mean as mean, @std as std into #result;
    UPDATE #result set mean = 10;
END
GO

For some reason, the Python code results in an error

sqlalchemy.exc.ProgrammingError: (pyodbc.ProgrammingError) [SQL Server]Invalid object name '#result'

Could somebody help me with this error?

0 Answers
Related