Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what's wrong retrivering data #63

Closed
valenciaj opened this issue Jul 24, 2017 · 8 comments
Closed

what's wrong retrivering data #63

valenciaj opened this issue Jul 24, 2017 · 8 comments

Comments

@valenciaj
Copy link

valenciaj commented Jul 24, 2017

I'm reading many rows from database table, but ALWAYS stop execution in this record.

my crystal code:

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 ??
@valenciaj
Copy link
Author

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

@bcardiff
Copy link
Member

bcardiff commented Jul 26, 2017

duplicate of crystal-lang/crystal-mysql#39

@RX14
Copy link
Contributor

RX14 commented Jul 26, 2017

@bcardiff I'm confused, waterlink/crystal-mysql#39 is about installing the mysql client lib?

@bcardiff
Copy link
Member

bcardiff commented Jul 26, 2017

@RX14 crystal-lang/crystal-mysql#39
I updated the link in the comment above now.

@bcardiff bcardiff marked this as a duplicate of crystal-lang/crystal-mysql#39 Jul 26, 2017
@RX14
Copy link
Contributor

RX14 commented Jul 26, 2017

I didn't realise we had 2 mysql bindings... It's a bit confusing, looks like waterlink/crystal-mysql isn't using crystal-db.

@valenciaj
Copy link
Author

Sorry, I'm a rookie in Crystal. Here is my shard.yml

dependencies:
  mysql:
    github: crystal-lang/crystal-mysql

@valenciaj
Copy link
Author

I dont know why is closed, it's a issue for crystal-mysql y for crystal-db? how can I kown this?

@bcardiff
Copy link
Member

@valenciaj please follow the discussion in crystal-lang/crystal-mysql#39 . let's lock this thread since it's probably an issue of mysql or the code that is using it.

@crystal-lang crystal-lang locked and limited conversation to collaborators Jul 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants