2

I've done a bit of googling, and I can't find much information on this. I have a MySQL table that I'm pushing data to that has a key column. The only writing to this table is from my python script. I know you can use "auto-increment" columns to keep the key generation a sanitary process. I also know that when you insert into the table using normal MySQL, you're supposed to push a SQL NULL in to the row to get it to auto-increment properly. How would I set up the rows to have the proper NULL? Can I use pandas NaNs or NoneTypes?

E: Here's a sample setup.

Table: Logbook
| Key | Date  | Notes      |
|  1  | 02-18 | Successful |
|  2  | 03-18 | Failure    |

Using SQL to insert to the table:

INSERT INTO Logbook
VALUES (NULL, 04-18, Failure)

I want to accomplish this with pd.to_sql

10
  • 1
    "you're supposed to push a SQL NULL in to the row to get it to auto-increment properly." What?
    – roganjosh
    Aug 16, 2018 at 15:23
  • 1
    What does 'push a sql null' mean?
    – Strawberry
    Aug 16, 2018 at 15:23
  • As in, when you INSERT into the table (as if you're executing a query), the value that goes in to the column that is auto incremented is NULL.
    – riders994
    Aug 16, 2018 at 15:27
  • Why would there be a need to set the auto-increment field as NULL? Aug 16, 2018 at 15:34
  • Because that's how it auto-increments? If I push a value, then it resets the autoincrementing from that value.
    – riders994
    Aug 16, 2018 at 15:38

0

Your Answer

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

Browse other questions tagged or ask your own question.