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
					
				| 
						 | 
				
			
			@ -207,6 +207,12 @@ The ``cursor`` class
 | 
			
		|||
 | 
			
		||||
        Parameters are bounded to the query using the same rules described in
 | 
			
		||||
        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::
 | 
			
		||||
            In its current implementation this method is not faster than
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1029,6 +1029,12 @@ parameters.  By reducing the number of server roundtrips the performance can be
 | 
			
		|||
 | 
			
		||||
.. 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
 | 
			
		||||
 | 
			
		||||
.. note::
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user