Skip to content

ElizaZu/kladr-mysql-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kladr-mysql-loader

Script for download and import Russian KLADR to MySQL database


Tested on ubuntu17.4 and Windows 10 (ubuntu for Windows 10)

How does it work:

  1. download the archive with Russian KLADR from official site https://www.gnivc.ru/html/gnivcsoft/KLADR/Base.7z
  2. convert dbf files to csv into UTF-8 encoding
  3. import csv into MySQL database

To run:

  1. Run the prerequisites file once. Will be installed (if not installed earlier): MySQL client, p7zip, python3.6, python-pip and python library for working with dbf
  2. In the file update_kladr.config configure the connection to the database and, if necessary, tables and columns aliases
    #Database server
    host=127.0.0.1
    #Database user
    user=kladruser
    #User's password
    password=kladrpassword
    #Database name
    database=kladr
  1. Run update_kladr. Attention! When you run the import, the previous data from kladr tables in database will be removed.

Code of dbf2csv.py taken from https://gist.github.com/bertspaan/8220892 Thank you!

Bash-скрипт для загрузки и экспорта КЛАДР в БД MySQL


Проверено на ubuntu17.4 и Windows 10 (ubuntu для Windows 10)

Выполняются следующие дествия:

  1. загрузку архива с КЛАДР с официального сайта https://www.gnivc.ru/html/gnivcsoft/KLADR/Base.7z
  2. конвертация dbf в csv в кодировку UTF-8
  3. импорт csv в БД MySQL

Для запуска:

  1. Один раз запустить prerequisites. Будут установлены, если не были установлены ранее: MySQL client, p7zip, python3.6, python-pip и библиотека питона для работы с dbf
  2. В файле update_kladr.config настроить параметры подключения к БД и при необходимости альясы таблиц и столбцов
   #Database server
   host=127.0.0.1
   #Database user
   user=kladruser
   #User's password
   password=kladrpassword
   #Database name
   database=kladr
  1. Запустить update_kladr. Внимание! При импорте предыдущие данные из указанных таблиц будут удалены.

Код скрипта на питоне для конвертации dbf в csv dbf2csv.py взят отсюда https://gist.github.com/bertspaan/8220892

About

Script for download and import Russian KLADR to MySQL database / Скрипт для загрузки и экспорта КЛАДР в БД MySQL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published