Questions tagged [executemany]

A method to prepare a database query or command and execute it against all parameters found in a sequence or mapping of parameters.

135 questions
1
vote
0 answers

pyodbc cursor.executemany() (insert) correctly fills the table but finish with the exit code -1073741571

Enviroment: python-3.6 pyodbc-4.0.23 mssql server 2014 When I use cursor.executemany() with cursor.fast_executemany = False to insert data to MSSQL table it works fine, but too slow (about 1h to write ~100000 rows). When I use…
1
vote
0 answers

Executemany gives "TypeError: not enough arguments for format string"

I'm trying to insert many rows in MySQL database and for some reason I'm always getting this error. I have already tried the solutions present in this topic and nothing works. TypeError: not enough arguments for format string My Code: cursor =…
1
vote
0 answers

Not all arguments converted during string formatting (using "question mark" placeholder in Python cursor.execute)

I followed the recommendations made here and here to insert records into a MySQL table, but the "not all arguments converted during string formatting" error persists. import csv import MySQLdb //snip// # MySQL server login code MyCSV =…
MBB70
  • 375
  • 2
  • 16
1
vote
1 answer

How can I perform a bulk insert with python in CrateDB?

I'm trying to do a bulk insert using python in CrateDB. The command executemany doesn't really perform a bulk insert, in the same way it does with SQL Server using pyodbc. With pyodbc I can use this: cursor.fast_executemany = True to solve the…
1
vote
1 answer

Getting KeyError while executing executemany command in python

Python code import pymysql import xlrd import re import os import csv conn = pymysql.connect(host='', user='', password='', db='', …
sarika
  • 35
  • 8
1
vote
2 answers

Using ? within INSERT INTO of a executemany() in Python with Sqlite

I am trying to submit data to a Sqlite db through python with executemany(). I am reading data from a JSON file and then placing it into the db. My problem is that the JSON creation is not under my control and depending on who I get the file from,…
1
vote
0 answers

Insert into database facebook posts in a list using python and executemany

I am using python, oursql and facebook SDK to scrape the data from Facebook and put it into the database. I wrote a function and manage to get the data in a list, but executemany puts into the database only first row. I don't know where the error…
m1k1
  • 143
  • 1
  • 2
  • 13
1
vote
2 answers

Loading data to Netezza as a list is very slow

I have about million records in a list that I would like to write to a Netezza table. I have been using executemany() command with pyodbc, which seems to be very slow (I can load much faster if I save the records to Excel and load to Netezza from…
user1124702
  • 1,015
  • 4
  • 12
  • 22
1
vote
1 answer

executemany throws error when I try inserting a list of tuples generated by list comprehension; same list works if it's hard-coded

executemany throws error when I try to insert a list of tuples that is generated using list compression, but works when insert the same list if it’s hard-code. When I try: a=[(i[0][0],i[0][1],i[0][2],i[1][0],i[1][1],i[0][5]) for i in…
1
vote
1 answer

In sql.executemany(... syntax error near '('

I'm trying to execute the following code in python, but it results in syntax error near '(' error for executemany(..). When I remove te names from sql and just write %s it also results in the error that there are more placeholders thant the…
user4103576
1
vote
2 answers

How does executemany() work

I have been using c++ and work with sqlite. In python, I have an executemany operation in the library but the c++ library I am using does not have that operation. I was wondering how the executemany operation optimizes queries to make them faster. I…
ThinkBonobo
  • 15,487
  • 9
  • 65
  • 80
1
vote
1 answer

pymssql executemany insert valueerror

I get an error: File "pymssql.pyx", line 443, in pymssql.Cursor.executemany (pymssql.c:6616) File "pymssql.pyx", line 417, in pymssql.Cursor.execute (pymssql.c:6057) File "_mssql.pyx", line 943, in _mssql.MSSQLConnection.execute_query…
Synal
  • 75
  • 3
  • 11
1
vote
3 answers

How to select many rows from a dictionary (executemany select)

I'm using Python and its MySQLdb module, is it possible to do a "selectmany"-like from a tuple/dictionary/list in the condition something like this: cursor.executemany("""SELECT * FROM customers WHERE name= %(name)s""",[d.__dict__ for d in…
user231339
1
vote
0 answers

How do I lazily pass csv rows to executemany()?

I'm using MySQL Connector/Python 1.0.11 with Python 3.3 and MySQL 5.6.12 to load a csv file into a table via cursor.executemany('INSERT INTO ... VALUES'). With sqlite3 or psycopg2 I can pass a _csv.reader object for seq_of_parameters, but MySQL…
Matthew Cornell
  • 4,114
  • 3
  • 27
  • 40
1
vote
0 answers

python's sqlite3.executemany: Alter a Table in a single transaction? Locking Error

I've an application, where I use sqlite3's autocommit feature everywhere which usually works fine. The app includes an database scheme updater. Basically it's just a set of SQL commands for each version upgrade, which should be called in a single…
Florian Lagg
  • 751
  • 2
  • 8
  • 21
1 2 3
8 9