python,database,pandas,executemany
I managed to figure this out in the end. So if you have a Pandas Dataframe which you want to write to a database using ceODBC which is the module I used, the code is: (with all_data as the dataframe) map dataframe values to string and store each row as...
I figured it out. The last line under cursor.executemany should read: """, input_list) I had the close parenthesis in the wrong place...
Writing ("/helloworld") is the same as writing "/helloworld". To create a tuple you need ("/helloworld", ). What you're doing is actually running this: cursor.executemany('''INSERT INTO fb_pages(fb_page) VALUES (%s)''', ["/helloworld","/dfadfadsfdas"]) And now the error you're receiving makes perfect sense - you're supplying two arguments with only one place holder. Defining entries_list...
python,mysql,pymssql,executemany
Since this is executemany(), it should be a list of dictionaries: upInfo = [{"aa": "aaa", "bb": "bbb", "cc": "ccc"}] Or, use a regular execute(): cur.execute(sql, upInfo) ...