2

I am using MySQL Connector/Python to run MySQL from my iPython notebook.

I am wondering, can I create a temporary table this way?

The documentation says nothing about temporary tables, and makes it seem that you would have to define a table before using it.

I am trying something along these lines:

cnx = mysql.connector.connect(user='me',
                              password='something',
                              host='somewhere',
                              port='3306',
                              database='some_db')
 
query = "CREATE TEMPORARY TABLE IF NOT EXISTS " +\
"my_temp_table " +\
"AS " +\
"SELECT a_col" +\
"FROM 
  . . . 
;"

When I try this from iPython, it runs and gives no response, yet the temp table has not shown up in the database.

Thanks for your help in advance.

1 Answer 1

3

my englist is poor

i think ,the mysql TEMPORARY TABLE for current session . when you close,the TEMPORARY TABLE is over.

http://dev.mysql.com/doc/refman/5.7/en/create-table.html You can use the TEMPORARY keyword when creating a table. A TEMPORARY table is visible only to the current session, and is dropped automatically when the session is closed.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.