0

I have connected my SQL Server to Python using sqlalchemy. Now I'm trying to use select statements to create 3 separate tables and ultimately join them. But none of my queries can ran through. Here's my code:

query2 = """
select AML_CUST_ID as AML_CUST_ID0,DATA_DT as DAY0,sum(CAST(AMT as float))as AMT0 into AML_Testing_DAY0 from dbo.trial2 
group by AML_CUST_ID,DATA_DT
"""
connection = engine.connect()
connection.execute(query2); 
connection.execute("SELECT * FROM AML_Testing_DAY0")  

Even though this code can run with no error, there's no table created in SQL Server. I have read on stackoverflow that this only creates a temp table, not a permanent table. Is there a way to create a permanent table? Thanks in advance for any inputs

2
  • Did you have a commit() somewhere in your code? Commented Apr 22, 2020 at 7:21
  • It looks like you're relying on autocommit, but SQLA does not recognize your statement as a data changing operation. Commented Apr 22, 2020 at 7:42

1 Answer 1

0

It will create a permanent table. Are you sure you're in the right database in the context of your session? Try adding three part naming, with the database before your schema/tables. If that's not the issue, try starting a trace with SQL Server Profiler to see what is happening.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.