csv_to_sqlite3 0.1.3 → 0.1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6054545a778a1f66aaf4f1a21d27a649495077eeb57156bc1c997fb35f4da2cd
4
- data.tar.gz: 806c76397accf1f4dd054e690ef033415d4fa8263bc8ca345057c116afdbe8e7
3
+ metadata.gz: e5f1dee4684b766e69ff16db70c84628b2eccf0f69e69b2f1584472cf46bcdf1
4
+ data.tar.gz: 3963bfc8ca100d2a1c4d57f0c5bfbf387708486c8f44f18af43c2e1353a7349d
5
5
  SHA512:
6
- metadata.gz: 82dea9f3753586ba249c11d820644086e44b8303333db6a06c381a02892d1f332c88f1031d084ac93c235757aa24dba8d7ddd72f3ac805a22f2501cb8507a53c
7
- data.tar.gz: 8f6623cb0bea64446b43ddc5421fd1fce24ef0c18413851ccc80c65ae5ca04dd6a734814276cb9b5d5960203cbda59d2306c399fb1a11cac4b732da9b2a9559e
6
+ metadata.gz: c9d0d144cde3c4aafa2e90a719cbe98d5c5b8ed3c25de09a0dc3582492bcf949e222c6c7da9d10890996a44d4d00242e5e9795795e75354365ce7ae7d4bfed0a
7
+ data.tar.gz: e29b9122c799b60d1ef6041714f6a67fba28c635f8dd37e3ee061f3d58b883af227e6c872f4188dccc4fb94e7e72e7434372bb90dfe10fe425ca101d34b75dd3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- csv_to_sqlite3 (0.1.2)
4
+ csv_to_sqlite3 (0.1.3.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # CsvToSqlite3
2
2
 
3
3
  CsvToSqlite3 is a gem that aims to work as a executable like rake or bundler, it servs as a Sqlite3 database generator from csv files. It is used to create and insert all data from one or more csv files to the same Sqlite3 database.
4
+
4
5
  The ideia comes from a specific cenario when I needed to run complex sql queries on a huge database, and once I was afraid to run it directly in prolduction and it impacts in the operation I chose to run simples selects (select * from some_table when created_at > some_date) from each table used on my query, export to csv files than create a specific ruby script that create a sqlite3 database and run the inserts, thereby i can run any havy query on my local computer without generate any impact in the operation.
6
+
5
7
  Once this cenario is quite common I decided to rewrite the script to work with any csv file exported from any table.
6
8
 
7
9
  ## Installation
@@ -14,6 +16,10 @@ Installed with gem:
14
16
 
15
17
  Once the gem is installed it is aviable the command "csv_to_sqlite", to generate a new database you need to run on terminal "csv_to_sqlite path/to/file.csv'". It will create a file named data.sqlite3 and create a table with name equal to file name, case the table already exists it will only insert all data from this file.
16
18
 
19
+ $ csv_to_sqlite stores.csv
20
+
21
+ By running the command above it will be generated a database data.sqlite3 with a table named stores with all data included.
22
+
17
23
  ## Development
18
24
 
19
25
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,4 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'csv_to_sqlite'
4
- CsvToSqlite::CsvToSqlite.convert(ARGV[0])
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'csv_to_sqlite'
4
- CsvToSqlite::CsvToSQLite.new.convert(ARGV[0])
4
+
5
+ CsvToSqlite::CsvToSQLite.new(ARGV).run
6
+
@@ -0,0 +1,29 @@
1
+ module CsvToSqlite
2
+ class ArgumentHandlerService
3
+
4
+ def initialize argv
5
+ @argv = argv
6
+ end
7
+
8
+ def call
9
+ return empty if @argv.empty?
10
+ return help if @argv.include? "-h"
11
+ :convert
12
+ end
13
+
14
+ def help
15
+ puts "Run csv_lto_sqlite3 is easy!"
16
+ puts "To convert a csv file into a sqlite3 database you just need to run the follow command from the same directory of the csv file:"
17
+ puts "csv_to_sqlite your_csv_file.csv"
18
+ puts "==============================="
19
+ puts "Some customisations will be aviable on next versions :)"
20
+ nil
21
+ end
22
+
23
+ def empty
24
+ puts "Run 'csv_to_sqlite -h' to receive some help or csv_to_sqlite csv_file.csv to generate a SQLite3 database from a csv file."
25
+ nil
26
+ end
27
+
28
+ end
29
+ end
@@ -3,12 +3,22 @@ require_relative "./database"
3
3
  require_relative "./csv_reader"
4
4
  require_relative "./sql/create_table"
5
5
  require_relative "./sql/insert"
6
+ require_relative "./argument_handler_service"
6
7
 
7
8
  module CsvToSqlite
8
9
  # class Error < StandardError; end
9
10
 
10
11
  class CsvToSQLite
11
12
 
13
+ def initialize argv
14
+ @args = argv
15
+ end
16
+
17
+ def run
18
+ method = CsvToSqlite::ArgumentHandlerService.new(@args).call
19
+ self.convert(@args.first) unless method.nil?
20
+ end
21
+
12
22
  def convert file_path
13
23
  connection = CsvToSqlite::Database.new().connect
14
24
  csv_table = CsvToSqlite::CsvReader.new(file_path).load_file
@@ -1,3 +1,3 @@
1
1
  module CsvToSqlite
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.3.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv_to_sqlite3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - joaofelipelopes
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-22 00:00:00.000000000 Z
11
+ date: 2020-10-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Add the executable "csv_to_sqlite" to your terminal, wich is used to
14
14
  create a SQLite3 database with all data from a csv file by running "csv_to_sqlite
@@ -34,6 +34,7 @@ files:
34
34
  - bin/setup
35
35
  - csv_to_sqlite3.gemspec
36
36
  - exe/csv_to_sqlite
37
+ - lib/argument_handler_service.rb
37
38
  - lib/csv_reader.rb
38
39
  - lib/csv_to_sqlite.rb
39
40
  - lib/csv_to_sqlite/version.rb
@@ -62,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
63
  - !ruby/object:Gem::Version
63
64
  version: '0'
64
65
  requirements: []
65
- rubygems_version: 3.0.3
66
+ rubygems_version: 3.1.2
66
67
  signing_key:
67
68
  specification_version: 4
68
69
  summary: An easy way to convert a csv file into SQLite3 database.