-
-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Description
I'm reading many rows from database table, but ALWAYS stop execution in this record.
my crystal code:
require "mysql"
require "yaml"
config = YAML.parse File.read "config.yml"
db = DB.open config["database"].to_s
index = 0
rs = db.query "SELECT * FROM destinations"
rs.each do
puts "#{ index += 1 } => #{ rs.read() }, #{ rs.read() }, #{ rs.read() }, #{ rs.read() }, #{ rs.read() }, #{ rs.read() }, #{ rs.read() }"
end
rs.close
db.close
Output:
1 => 10000, 10000, Andorra, 0.016224, 0.048672, 2017-07-13 18:14:08, 2017-07-13 18:17:51
2 => 10001, 10000, Andorra-Mobile, 0.1404, 0.4212, 2017-07-13 18:14:08, 2017-07-13 18:19:11
3 => 10002, 10004, Anguilla, 0.122616, 0.367848, 2017-07-13 18:14:08, 2017-07-13 18:17:51
4 => 10003, 10003, Antigua Barbuda, 0.248508, 0.745524, 2017-07-13 18:14:08, 2017-07-13 18:14:08
5 => 10004, 10010, Argentina, 0.02106, 0.06318, 2017-07-13 18:14:08, 2017-07-13 18:17:51
... omit verbose ...
351 => 10351, 10179, Portugal-Freephone, 0.01426, 0.04278, 2017-07-13 18:14:08, 2017-07-13 18:19:12
352 => 10352, 10179, Portugal-Mobile-Optimus, 0.012948, 0.038844, 2017-07-13 18:14:08, 2017-07-13 18:19:12
353 => 10353, 10179, Portugal-Mobile-Others, 0.01482, 0.04446, 2017-07-13 18:14:08, 2017-07-13 18:19:12
354 => 10354, 10179, Portugal-Mobile-TMN, 0.01482, 0.04446, 2017-07-13 18:14:08, 2017-07-13 18:19:12
355 => 10355, 10179, Portugal-Mobile-Vodafone, 0.012948, 0.038844, 2017-07-13 18:14:08, 2017-07-13 18:19:12
Invalid Float64: Portugal-OLO-1 (ArgumentError)
0x490a97: *CallStack::unwind:Array(Pointer(Void)) at ??
0x4aa477: to_f64 at /opt/crystal/src/string.cr 666:56
0x4ab6eb: to_f64 at /opt/crystal/src/string.cr 665:3
0x513cae: read at /home/javier/projects/crystal/facturalia-pms/lib/mysql/src/mysql/types.cr 190:7
0x513786: read at /home/javier/projects/crystal/facturalia-pms/lib/mysql/src/mysql/result_set.cr 81:13
0x4780b8: __crystal_main at /home/javier/projects/crystal/facturalia-pms/facturalia-pms.cr 24:78
0x48b229: main at /opt/crystal/src/main.cr 12:15
0x7f52a954eb45: __libc_start_main at ??
0x4767ed: ??? at ??
0x0: ??? at ??
I try to modify query to:
SELECT * FROM destinations WHERE id >= 10350
Now can see this record:
1 => 10350, 10179, Portugal, 0.002986, 0.008958, 2017-07-13 18:14:08, 2017-07-13 18:17:52
2 => 10351, 10179, Portugal-Freephone, 0.01426, 0.04278, 2017-07-13 18:14:08, 2017-07-13 18:19:12
3 => 10352, 10179, Portugal-Mobile-Optimus, 0.012948, 0.038844, 2017-07-13 18:14:08, 2017-07-13 18:19:12
4 => 10353, 10179, Portugal-Mobile-Others, 0.01482, 0.04446, 2017-07-13 18:14:08, 2017-07-13 18:19:12
5 => 10354, 10179, Portugal-Mobile-TMN, 0.01482, 0.04446, 2017-07-13 18:14:08, 2017-07-13 18:19:12
6 => 10355, 10179, Portugal-Mobile-Vodafone, 0.012948, 0.038844, 2017-07-13 18:14:08, 2017-07-13 18:19:12
7 => 10356, 10179, Portugal-OLO-1, 0.004858, 0.014574, 2017-07-13 18:14:08, 2017-07-13 18:19:12
8 => 10357, 10179, Portugal-OLO-2, 0.004858, 0.014574, 2017-07-13 18:14:08, 2017-07-13 18:19:12
9 => 10358, 10179, Portugal-Personal Number, 0.0138, 0.0414, 2017-07-13 18:14:08, 2017-07-13 18:19:12
10 => 10359, 10179, Portugal-Shared Cost, 0.0138, 0.0414, 2017-07-13 18:14:08, 2017-07-13 18:19:12
... omit verbose ...
Program end normally
Metadata
Metadata
Assignees
Labels
No labels