mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-11-04 01:37:31 +03:00 
			
		
		
		
	Add executemany & execute_batch examples
This commit is contained in:
		
							parent
							
								
									a12dbc4357
								
							
						
					
					
						commit
						aabac5df31
					
				| 
						 | 
					@ -208,6 +208,12 @@ The ``cursor`` class
 | 
				
			||||||
        Parameters are bounded to the query using the same rules described in
 | 
					        Parameters are bounded to the query using the same rules described in
 | 
				
			||||||
        the `~cursor.execute()` method.
 | 
					        the `~cursor.execute()` method.
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					            >>> nums = ((1,), (5,), (10,))
 | 
				
			||||||
 | 
					            >>> cur.executemany("INSERT INTO test (num) VALUES (%s)", nums)
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            >>> tuples = ((123, "foo"), (42, "bar"), (23, "baz"))
 | 
				
			||||||
 | 
					            >>> cur.executemany("INSERT INTO test (num, data) VALUES (%s, %s)", tuples)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        .. warning::
 | 
					        .. warning::
 | 
				
			||||||
            In its current implementation this method is not faster than
 | 
					            In its current implementation this method is not faster than
 | 
				
			||||||
            executing `~cursor.execute()` in a loop. For better performance
 | 
					            executing `~cursor.execute()` in a loop. For better performance
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1029,6 +1029,12 @@ parameters.  By reducing the number of server roundtrips the performance can be
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. autofunction:: execute_batch
 | 
					.. autofunction:: execute_batch
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    >>> nums = ((1,), (5,), (10,))
 | 
				
			||||||
 | 
					    >>> execute_batch(cur, "INSERT INTO test (num) VALUES (%s)", nums)
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					    >>> tuples = ((123, "foo"), (42, "bar"), (23, "baz"))
 | 
				
			||||||
 | 
					    >>> execute_batch(cur, "INSERT INTO test (num, data) VALUES (%s, %s)", tuples)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    .. versionadded:: 2.7
 | 
					    .. versionadded:: 2.7
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. note::
 | 
					.. note::
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user