{"id":4092,"date":"2024-07-23T09:39:30","date_gmt":"2024-07-23T02:39:30","guid":{"rendered":"https:\/\/www.sqlservertutorial.net\/?page_id=4092"},"modified":"2024-07-24T19:43:55","modified_gmt":"2024-07-24T12:43:55","slug":"python-sql-server-bulk-copy","status":"publish","type":"page","link":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-bulk-copy\/","title":{"rendered":"Python SQL Server: Bulk Copy"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to quickly insert data into the SQL Server table using the bulk copy function.<\/p>\n\n\n\n<p class=\"note\">This tutorial begins where\u00a0the\u00a0<a href=\"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-import-from-csv\/\">import data from a CSV file into a SQL Server table tutorial<\/a>\u00a0left off.<\/p>\n\n\n\n<p>To quickly insert a lot of data into the SQL Server table, you can use the bulk copy function. We&#8217;ll demonstrate how to perform a bulk data copy into the <code>Customers<\/code> table.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='perform-a-bulk-copy-of-customer-data'>Perform a bulk copy of customer data <a href=\"#perform-a-bulk-copy-of-customer-data\" class=\"anchor\" id=\"perform-a-bulk-copy-of-customer-data\" title=\"Anchor for Perform a bulk copy of customer data\">#<\/a><\/h2>\n\n\n\n<p>Step 1. Download and copy the following <code>customers.csv<\/code> data into the data directory:<\/p>\n\n\n\n<p><a href=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/customers.zip\" target=\"_blank\" rel=\"noreferrer noopener\">Download the customers.csv file<\/a><\/p>\n\n\n\n<p>The <code>customers.csv<\/code> file includes 500 customer records, with all the columns from the <code>Customers<\/code> table including <code>CustomerID<\/code>, <code>FirstName<\/code>, <code>LastName<\/code>, <code>Email<\/code>, <code>PhoneNumber<\/code>, and <code>Address<\/code>.<\/p>\n\n\n\n<p>Step 2. Create a new file <code>bulk.py<\/code> within the project directory:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">mkdir data<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Step 3. Add the following code to the <code>bulk.py<\/code> file:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">from<\/span> connect <span class=\"hljs-keyword\">import<\/span> create_connection\n<span class=\"hljs-keyword\">from<\/span> utils <span class=\"hljs-keyword\">import<\/span> read_csv\n\n\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">bulk_copy_customers<\/span><span class=\"hljs-params\">(filename:str)<\/span> -&gt; bool:<\/span>\n    customers = read_csv(filename)\n    <span class=\"hljs-keyword\">if<\/span> <span class=\"hljs-keyword\">not<\/span> customers:\n        <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">False<\/span>\n    \n    conn = create_connection()\n    <span class=\"hljs-keyword\">if<\/span> conn <span class=\"hljs-keyword\">is<\/span> <span class=\"hljs-literal\">None<\/span>:\n        <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">False<\/span>\n    \n    <span class=\"hljs-keyword\">with<\/span> conn:\n        conn.bulk_copy(<span class=\"hljs-string\">'Customers'<\/span>,customers)\n        conn.commit()\n\n    <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">True<\/span>   <\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works.<\/p>\n\n\n\n<p>First, import <code>create_connection<\/code> function from the <code>connect<\/code> module and <code>read_csv<\/code> function from the utils module:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">from<\/span> connect <span class=\"hljs-keyword\">import<\/span> create_connection\n<span class=\"hljs-keyword\">from<\/span> utils <span class=\"hljs-keyword\">import<\/span> read_csv<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Here&#8217;s more information on the <a href=\"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-connect-to-sql-server\/\">connect<\/a> and <a href=\"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-import-from-csv\/\">utils<\/a> modules.<\/p>\n\n\n\n<p>Second, define a function <code>bulk_copy_customers<\/code> that accepts a CSV file name as a string and returns a boolean value indicating whether the bulk copy succeeds:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">bulk_copy_customers<\/span><span class=\"hljs-params\">(filename:str)<\/span> -&gt; bool:<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, read the customer data from the CSV file specified by the filename argument, and return False if the customer file is empty:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">customers = read_csv(filename)\n<span class=\"hljs-keyword\">if<\/span> <span class=\"hljs-keyword\">not<\/span> customers:\n    <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">False<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fourth, create a new connection to the SQL Server by calling the <code>create_connection<\/code> function, and return False if the connection fails:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">conn = create_connection()\n<span class=\"hljs-keyword\">if<\/span> conn <span class=\"hljs-keyword\">is<\/span> <span class=\"hljs-literal\">None<\/span>:\n    <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">False<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fifth, call the <code>bulk_copy<\/code> function of the Connection object to perform a bulk copy:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">with<\/span> conn:\n    conn.bulk_copy(<span class=\"hljs-string\">'Customers'<\/span>,customers)\n    conn.commit()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>bulk_copy<\/code> function accepts a table name and a list of tuples, with each tuple containing data representing a customer record.<\/p>\n\n\n\n<p>The <code>with<\/code> statement ensures that the <code>Connection<\/code> object is managed properly so you don&#8217;t have to manually close it.<\/p>\n\n\n\n<p>The <code>commit()<\/code> method permanently applies changes to the database. If you don&#8217;t call the <code>commit()<\/code> method, the changes won&#8217;t be saved to the database.<\/p>\n\n\n\n<p>Finally, return True from the function to indicate that the bulk copy was successful:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">True<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Step 4. Modify the <code>main.py<\/code> module that uses the <code>bulk_copy_customers<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import<\/span> logging, sys\n<span class=\"hljs-keyword\">from<\/span> bulk <span class=\"hljs-keyword\">import<\/span> bulk_copy_customers \n\n<span class=\"hljs-comment\"># config logging to console<\/span>\nlogging.basicConfig(\n    stream=sys.stdout, \n    encoding=<span class=\"hljs-string\">'utf-8'<\/span>, \n    format=<span class=\"hljs-string\">'%(levelname)s:%(message)s'<\/span>,\n    level=logging.DEBUG\n)\n\nbulk_copy_customers(<span class=\"hljs-string\">'.\/data\/customers.csv'<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works.<\/p>\n\n\n\n<p>First, import logging and sys for logging purposes:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import<\/span> logging, sys<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, import the <code>bulk_copy_customers<\/code> function from the <code>bulk<\/code> module:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">from<\/span> bulk <span class=\"hljs-keyword\">import<\/span> bulk_copy_customers<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, configure the logging to output messages to the terminal:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">logging.basicConfig(\n    stream=sys.stdout, \n    encoding=<span class=\"hljs-string\">'utf-8'<\/span>, \n    format=<span class=\"hljs-string\">'%(levelname)s:%(message)s'<\/span>,\n    level=logging.DEBUG\n)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Finally, call the <code>bulk_copy_customers<\/code> function to copy customer data from the .\/data\/<code>customers.csv<\/code> to the Customers table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">bulk_copy_customers(<span class=\"hljs-string\">'.\/data\/customers.csv'<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Step 5. Open your terminal and run the <code>main.py<\/code> file:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">python main.py<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='verifying-the-bulk-copy'>Verifying the bulk copy <a href=\"#verifying-the-bulk-copy\" class=\"anchor\" id=\"verifying-the-bulk-copy\" title=\"Anchor for Verifying the bulk copy\">#<\/a><\/h2>\n\n\n\n<p>Step 1. Launch SQL Server Management Studio and connect to the SQL Server.<\/p>\n\n\n\n<p>Step 2. Execute the following query that retrieves data from the <code>Customers<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">SELECT * FROM customers;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"757\" height=\"255\" src=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/python-sql-server-pymssql-bulk-copy.png\" alt=\"python sql server pymssql bulk copy\" class=\"wp-image-4096\" srcset=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/python-sql-server-pymssql-bulk-copy.png 757w, https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/python-sql-server-pymssql-bulk-copy-300x101.png 300w\" sizes=\"auto, (max-width: 757px) 100vw, 757px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id='download-the-project-source-code'>Download the project source code <a href=\"#download-the-project-source-code\" class=\"anchor\" id=\"download-the-project-source-code\" title=\"Anchor for Download the project source code\">#<\/a><\/h2>\n\n\n\n<p><a href=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/Python-SQL-Server-Bulk-Copy.zip\">Download the project source code<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the <code>bulk_copy()<\/code> method of the Connection object to quickly load data into an SQL Server table.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"4092\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-bulk-copy\/\"\n\t\t\t\tdata-post-title=\"Python SQL Server: Bulk Copy\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"4092\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-bulk-copy\/\"\n\t\t\t\tdata-post-title=\"Python SQL Server: Bulk Copy\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to quickly insert data into the SQL Server table using the bulk copy function.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":4049,"menu_order":3,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-4092","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python SQL Server: Bulk Copy<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn how to quickly insert data into the SQL Server table using the bulk copy function.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-bulk-copy\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python SQL Server: Bulk Copy\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn how to quickly insert data into the SQL Server table using the bulk copy function.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-bulk-copy\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Server Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-24T12:43:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/python-sql-server-pymssql-bulk-copy.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/python-sql-server\\\/python-sql-server-bulk-copy\\\/\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/python-sql-server\\\/python-sql-server-bulk-copy\\\/\",\"name\":\"Python SQL Server: Bulk Copy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/python-sql-server\\\/python-sql-server-bulk-copy\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/python-sql-server\\\/python-sql-server-bulk-copy\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/python-sql-server-pymssql-bulk-copy.png\",\"datePublished\":\"2024-07-23T02:39:30+00:00\",\"dateModified\":\"2024-07-24T12:43:55+00:00\",\"description\":\"In this tutorial, you will learn how to quickly insert data into the SQL Server table using the bulk copy function.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/python-sql-server\\\/python-sql-server-bulk-copy\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlservertutorial.net\\\/python-sql-server\\\/python-sql-server-bulk-copy\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/python-sql-server\\\/python-sql-server-bulk-copy\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/python-sql-server-pymssql-bulk-copy.png\",\"contentUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/python-sql-server-pymssql-bulk-copy.png\",\"width\":757,\"height\":255,\"caption\":\"python sql server pymssql bulk copy\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/python-sql-server\\\/python-sql-server-bulk-copy\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python SQL Server\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/python-sql-server\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python SQL Server: Bulk Copy\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\",\"name\":\"SQL Server Tutorial\",\"description\":\"The Practical SQL Server Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python SQL Server: Bulk Copy","description":"In this tutorial, you will learn how to quickly insert data into the SQL Server table using the bulk copy function.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-bulk-copy\/","og_locale":"en_US","og_type":"article","og_title":"Python SQL Server: Bulk Copy","og_description":"In this tutorial, you will learn how to quickly insert data into the SQL Server table using the bulk copy function.","og_url":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-bulk-copy\/","og_site_name":"SQL Server Tutorial","article_modified_time":"2024-07-24T12:43:55+00:00","og_image":[{"url":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/python-sql-server-pymssql-bulk-copy.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-bulk-copy\/","url":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-bulk-copy\/","name":"Python SQL Server: Bulk Copy","isPartOf":{"@id":"https:\/\/www.sqlservertutorial.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-bulk-copy\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-bulk-copy\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/python-sql-server-pymssql-bulk-copy.png","datePublished":"2024-07-23T02:39:30+00:00","dateModified":"2024-07-24T12:43:55+00:00","description":"In this tutorial, you will learn how to quickly insert data into the SQL Server table using the bulk copy function.","breadcrumb":{"@id":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-bulk-copy\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-bulk-copy\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-bulk-copy\/#primaryimage","url":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/python-sql-server-pymssql-bulk-copy.png","contentUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/python-sql-server-pymssql-bulk-copy.png","width":757,"height":255,"caption":"python sql server pymssql bulk copy"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-bulk-copy\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlservertutorial.net\/"},{"@type":"ListItem","position":2,"name":"Python SQL Server","item":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/"},{"@type":"ListItem","position":3,"name":"Python SQL Server: Bulk Copy"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlservertutorial.net\/#website","url":"https:\/\/www.sqlservertutorial.net\/","name":"SQL Server Tutorial","description":"The Practical SQL Server Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlservertutorial.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/4092","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/comments?post=4092"}],"version-history":[{"count":5,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/4092\/revisions"}],"predecessor-version":[{"id":4193,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/4092\/revisions\/4193"}],"up":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/4049"}],"wp:attachment":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media?parent=4092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}