Skip to main content

This is a python utility that allows users to import/export data to/from a database.

Project description

BCP

< badges will go here >

This is a python utility that allows users to import/export data to/from a database.


Overview

This library began as a wrapper around SQL Server's BCP utility. It makes some assumptions about parameters to simplify the interface and allow the user to work natively in python. Though it currently supports MSSQL, there are plans to extend support to other database dialects.

Requirements

  • Python 3.6+

This library purposely requires no python packages outside of the standard library, beyond testing and documentation needs. The intention is to maintain this status. However, you will need to have the appropriate command line utilities installed for the specific database dialects with which you'll interact. For example, if your database is a MS SQL SERVER instance, you'll need BCP installed. Consult the table below for further documentation, including download files and instructions.

RDBMS Utility Documentation / Installation
MS SQL Server BCP https://docs.microsoft.com/en-us/sql/tools/bcp-utility

Installation

This library is still in development. So you'll have to build it from source in the meantime. I'll soon get around to publishing it on pypi, in which case you'll be able to install it using pip

pip install bcp

Examples

Import data:

from bcp import BCP, Connection, DataFile

conn = Connection(host='HOST', driver='mssql', username='USER', password='PASSWORD')
my_bcp = BCP(conn)
file = DataFile(file_path='path/to/file.csv', delimiter=',')
my_bcp.load(file, 'table_name')

Export data:

from bcp import BCP, Connection

conn = Connection(host='HOST', driver='mssql', username='USER', password='PASSWORD')
my_bcp = BCP(conn)
file = my_bcp.dump('select * from sys.tables')
print(file)  # %USERPROFILE%/bcp/data/<timestamp>.tsv

Full Documentation

For the full documentation, please visit: https://bcp.readthedocs.io/en/latest/

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for bcp, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size bcp-0.2.1-py3-none-any.whl (24.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page