npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

singlemysqlcsv-cli

v0.0.1

Published

mysql single column update with csv file.

Downloads

3

Readme

singlemysqlcsv-cli

  • mysql update by csv
  • singlemydqlcsv can update single column at once.
  • not support multi column update

Install

npm inatall singlemysqlcsv-cli

Support features:

  • Update mysql single column
  • Select key column
  • Typescript support

Update Logic

  • if mysql table name TableA have 3 Column CA, CB, CC and CA is main Key
  • if A.csv have CSA key column and CSC column
  • this module can be update column that one of TableA at once
  • first of all select table
  • second, select key column, this key column match to csv key column
  • third, select table's column for update
  • 4th, select csv file
  • 5th, select csv key column, this key column match to db table key column
  • 6th, select csv's column for update

How to run

  • bin
    • global npm install
    singlemysqlcsv-cli
  • code
    - npm run start
  • running
        PS D:\dev\npms\csvupdater> npm run start                                                                                
    > [email protected] start D:\dev\npms\csvupdater
    > nodemon --watch src --delay 1 --exec ts-node src/index.ts
    
    [nodemon] 2.0.6
    [nodemon] to restart at any time, enter `rs`
    [nodemon] watching path(s): src\**\*
    [nodemon] watching extensions: ts,json
    [nodemon] starting `ts-node src/index.ts`
    ____  ____    _  ____ ______     ___     __  _ ____  ____  _   _   _           _       _          ___   _
    / ___|| __ )  ( )/ ___/ ___\ \   / ( )    \ \( )  _ \| __ )( ) | | | |_ __   __| | __ _| |_ ___   / _ \ / |
    \___ \|  _ \  |/| |   \___ \\ \ / /|/ _____\ \/| | | |  _ \|/  | | | | '_ \ / _` |/ _` | __/ _ \ | | | || |
    ___) | |_) |   | |___ ___) |\ V /   |_____/ / | |_| | |_) |   | |_| | |_) | (_| | (_| | ||  __/ | |_| || |
    |____/|____/     \____|____/  \_/         /_/  |____/|____/     \___/| .__/ \__,_|\__,_|\__\___|  \___(_)_|
                                                                        |_|
    => Target DB host(default "localhost")?
    => Target DB user? quser
    => Target DB password? quser
    => Target DB database? sessions
    success connection
    => Source CSV file path? ./source.csv
    7 row read
    ** Current CSV keys are ID,name,desc
    => Select Key Column: ID
    => Select Updated Data Column: name
    CSV "ID" ---> mapping Table and Column Select:
    => Select Mapping DB Table: test
    => Select Mapping DB Key Column: id
    => Select Mapping DB Update Column: name
    => "ID" mapping --> "test/id" sure?(y/n)y
    => "name" update --> "test/name" sure?(y/n)y
    **************************************************************************
    Key Mapping CSV[ID]--> DB[test/id]
    Update Mapping CSV[name]--> DB[test/name]
  • let see, above example

  • this example show how to update sessions DB by using source.csv file.

  • as you can see, sessions DB's test table have id column, this id column is matched source.csv id column. and name column update by soure.csv name column.

        if(sessions.test.id == source.csv.id) {
            sessions.test.name = source.csv.name
        }
  • above pseudocode can expain total logic.

Build

  • npm run build
    • out put folder is 'dist'