I'm trying to create a table on a tempdb database on a local server KHBW001 using MSSQL. My code is:
import pyodbc
connection = pyodbc.connect('Driver={SQL Server};'
'Server=KHBW001;'
'Database=tempdb;'
'Trusted_Connection=yes;')
cursor = connection.cursor()
cursor.executemany(
"CREATE TABLE tempdb.dbo.NewTestPyTable(Symbol varchar(15), Shares integer, Price double)") # creates new table
cursor.executemany("""
INSERT INTO tempdb.dbo.NewTestPyTable (Symbol, Shares, Price)
VALUES
[('ETH',55,199.55),
('KHC',66,33.5)]
""") # insert two records into new table
connection.commit()
I'm getting the error:
"CREATE TABLE tempdb.dbo.NewTestPyTable(Symbol varchar(15), Shares integer, Price double)") # creates new table
TypeError: function takes exactly 2 arguments (1 given)
I don't quite understand what I'm doing wrong. Please assist
executemanyas opposed toexecute--> github.com/mkleehammer/pyodbc/wiki/…TypeError: function takes exactly 2 arguments (1 given)