GithubHelp home page GithubHelp logo

alitrack / pgcopy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from altaurog/pgcopy

0.0 1.0 0.0 210 KB

fast data loading with binary copy

Home Page: https://pgcopy.readthedocs.io/

License: Other

Shell 0.24% Python 98.98% Dockerfile 0.79%

pgcopy's Introduction

pgcopy

image

image

image

image

image

Use pgcopy for fast data loading into PostgreSQL with binary copy.

Features

  • Support for many data types
  • Support for multi-dimensional array types
  • Support for schema and schema search path
  • Transparent string encoding
  • Utility for replacing entire table

Quickstart

from datetime import datetime
from pgcopy import CopyManager
import psycopg2
cols = ('id', 'timestamp', 'location', 'temperature')
now = datetime.now()
records = [
        (0, now, 'Jerusalem', 72.2),
        (1, now, 'New York', 75.6),
        (2, now, 'Moscow', 54.3),
    ]
conn = psycopg2.connect(database='weather_db')
mgr = CopyManager(conn, 'measurements_table', cols)
mgr.copy(records)

# don't forget to commit!
conn.commit()

Supported datatypes

pgcopy supports the following PostgreSQL scalar types:

  • bool
  • smallint
  • integer
  • bigint
  • real
  • double precision
  • char
  • varchar
  • text
  • bytea
  • enum types
  • date
  • time
  • timestamp
  • timestamp with time zone
  • numeric
  • json
  • jsonb
  • uuid
  • arrays

Documentation

Read the docs.

See Also

cpgcopy, a Cython implementation, about twice as fast.

pgcopy's People

Contributors

altaurog avatar mastak avatar johnbachman avatar nathanglover avatar akshayeshenoi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.