A method to prepare a database query or command and execute it against all parameters found in a sequence or mapping of parameters.
Questions tagged [executemany]
135 questions
0
votes
0 answers
How can I insert all items in a list into postgres at once?
I have a python list, which has ~20k items in it. These are integers.
I would like to INSERT all these integers.
For integers that already exist, I would like to increment the second row, that we'll call amount by one.
Since there are ~20k items, it…

Enz
- 99
- 6
0
votes
1 answer
AttributeError: 'pyodbc.Connection' object has no attribute 'executemany'
these are 2 classes dbclient and mykiosk client,
im trying to run those 4 lines of code below
but Im getting the AttributeError. I just want to get api data into sql table through python keeping this format in mind. Can someone please help me…

tp_
- 7
- 2
- 6
0
votes
1 answer
cx-oracle-executemany()-batch-insert-error-expecting-number
I have a list
bind_insert:
[(3, 18, '01-10-2021', 'M51078', 'AABCM5192K', '01280', 'AABCM5192K', None, None, 'X95091', 'AZEPK0300N',
'C', 'CO', 'N01477', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,…

Alok Sharma
- 95
- 1
- 12
0
votes
1 answer
Can I use executemany for a large batch process with sqlite3?
I have a pretty long python process that is meant to reprocess a massive amount of data from one table, extract the necessary pieces, assign appropriate values and reenter it into another table. The process works great! Except that it is incredibly…

MAb2021
- 127
- 9
0
votes
0 answers
Python MySQLdb cursor executemany on massive insert not working
I am working on a Python script that reads data from a big excel file and stores the necessary data on corresponding dictionary variables.
Once all of the file's data is read and processed, the script iterates through all the dictionaries by 100…

Julio Garcia
- 393
- 2
- 7
- 22
0
votes
1 answer
SQL OperationalError: near "%": syntax error when using inserting values into a table with "executemany"
I have been trying to insert values into a table with the following code:
top10_strong_beers.values.tolist() =
[['Surly Brewing Company', 'Abrasive Ale', 2020, 1],
['Modern Times Beer', 'Blazing World', 2020, 2],
['Sixpoint Craft Ales', 'Hi-Res',…

Kathy
- 1
- 1
0
votes
0 answers
executemany method in mysql.connector with utf8mb4 charset not working (python)
A few days ago I posted a problem regarding inserting emojis in a MariaDB database using the mysql.connector module in Python. Now after further investigations I was able to narrow the problem down. After changing the charset and collation of the…

JonaWe
- 21
- 1
- 6
0
votes
1 answer
Inserting into MySQL from Python using mysql.connector module - How to use executemany() to inert rows and child rows?
I have a MySQL server running on a remote host. The connection to the host is fairly slow and it affects the performance of the Python code I am using. I find that using the executemany() function makes a big improvement over using an loop to insert…

Calab
- 351
- 4
- 20
0
votes
1 answer
Python: Incorrect number of bindings supplied when EXECUTEMANY
Trying to pick up some python. I'm quite new to it at the moment.
I created the code below, but it returns an error.
I am able to get it to work when creating a second column and write multiple values to the db but a single value doesn't seem to…

Niemorce
- 3
- 3
0
votes
0 answers
ExecuteMany inserting wrong values in NUMBER column: too large values instead of actual value
I am doing bulk insertion using executeMany in node-oracle db. It executes successfully , but the Numbers with decimal points are being inserted as a false very large value ...
Actual values are for eg. 102.22, 456672.89 but they are being inserted…

Sana.91
- 1,999
- 4
- 33
- 52
0
votes
1 answer
Django cursor.executemany what's the preferred batch size for each "executemany"
I use the following code to do bulk insert with extended "insert into".
cursor = connections['default'].cursor()
sql = "INSERT INTO %s (%s) VALUES ([xxx], [xxx], ...) "
step = 1000
for l in range(0, len(values), step):
…

Mayling
- 3
- 5
0
votes
0 answers
Python array to mysql DB
Why i can't save a array list to mysql DB ^^.
This Script work
Code work:
########################################
# Importing modules
import mysql.connector
conn = mysql.connector.connect(
host="localhost",
user="*******",
…

epiker
- 11
- 1
0
votes
0 answers
Question related to SQL Server Driver support for pyodbc's fast_executemany option
I am trying to improve insert performance to a SQL Server Database table using Python. (First step taken is instead of row by row insert, prepare a bulk statement.)
After going through driver support documentation (…

MDixit
- 3
- 2
0
votes
2 answers
Efficiently delete multiple records
I am trying to execute a delete statement that checks if the table has any SKU that exists in the SKU column of the dataframe. And if it does, it deletes the row. As I am using a for statement to iterate through the rows and check, it takes a long…

loraine
- 39
- 1
- 7
0
votes
2 answers
Writing Generic cursor.executemany() in python
Im new to python, trying to write a generic function that has arguments as the list of dictionaries, tablename, dbusername, password and Insert different data in to different tables like below
dict_list=[{'name': 'sandeep', 'age': '10'}, {'name':…

Sandy
- 57
- 1
- 8