Giter Club home page Giter Club logo

hlook's Introduction

hlook

A small script for uploading data from files .json, .xml or .csv into mysql database.

To run the script, you need:

  • python 3.x
  • peewee >= 3.6.0
  • pymysql
  • mysql (script for creating database included)

Usage

main.py [-h] -f FILENAME -H HOST [-p PORT] -u USERNAME -P [PASSWORD] [-d DATABASE]

Loading data from files .json, .xml or .csv into mysql database.

optional arguments:

-h, --help show this help message and exit

-f FILENAME, --fileName FILENAME path to a file

-H HOST, --host HOST ip-address of the database for uploading data

-p PORT, --port PORT port of the database for uploading data (default=3306)

-u USERNAME, --username USERNAME username of the database

-P [PASSWORD], --password [PASSWORD] password for the database user

-d DATABASE, --database DATABASE type of the database: mysql, postgresql (default=mysql)

hlook's People

Contributors

swetlana-spb avatar

hlook's Issues

Code review

  1. не понятно зачем в парсере нужна переменная dataList и весь метод constructDataLine. каждый парсер собирает данные в список, а затем constructDataLine перестраивает их в словарь. почему нельзя сразу собирать словарь? как по мне, dataList это лишняя переменная, которая занимает память и увеличивает возможность ошибки (если перепутать местами строки, то в словарь данные запишутся в неправильные поля).
  2. в модели Photos поле master_id это внешний ключ (ForeignKey). тут не нужно изобретать велик :) нужно жестко связать через него модели Photos и Information.
  3. и последнее, самое жестокое :) вот такое сохранение записей в бд как тут https://github.com/swetlana-spb/hlook/blob/master/database.py#L23-L36 это очень не красиво. во-первых, из-за отсутствия ForeignKey ты делаешь кучу лишней работы, а во-вторых, ты сохраняешь записи в базу по одной штуке, что довольно дорого для больших файлов. я бы предложил использовать вставку данных пачкой (bulk inserts).

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.