Closed vorobeez closed 9 years ago
Thanks for checking out the driver!
If you are running RethinkDB on localhost:8080
then try this:
r->connect('localhost', 8080)->repl;
r->db('test')->create->run;
r->db('test')->table('test_table')->create->run;
r->db('test')->table('test_table')->insert([
id => 1,
name => 'test',
])->run;
If you use the repl
method, it will keep track of your initial connection for you. Otherwise, just run my $io = r->connect();
and pass $io
to all of the run
methods. E.g.
my $io r->connect('localhost', 8080);
my $res = r->db('test')->table('test_table')->run($io);
say Dumper $res;
If you want to see the messages from the database (errors, success, etc) just look at the return value from any of the queries.
@njlg, greetings!
here is my script:
#!/usr/bin/perl
use warnings;
use strict;
use 5.022;
use Rethinkdb;
my $log;
open $log, '>', 'logfile';
my $res_connect = r->connect('localhost', 8080)->repl;
say $log $res_connect;
my $res_db_create = r->db('test')->create->run;
say $log $res_db_create;
my $res_table_create = r->db('test')->table('test_table')->create->run;
say $log $res_table_create;
my $res_row_insert = r->db('test')->table('test_table')->insert([
id => 1,
name => 'test',
])->run;
say $log $res_row_insert;
close $log;
I have the same problem. My script just freezes, no changes in database and logfile is empty.
Do you know for a fact that you are running RethinkDB on port 8080? By default it listens for database connections on port 28015. I believe that when you make a connection to the web interface, it will accept the connection but never respond. (Which might be a good issue for me to look into)
@njlg, Thank you very much for your help and for your wasted time. Sorry for my inattention =/ (Now everything work fine)
Great. No problem. Glad you are trying the driver out.
Hello. I was tried to use your driver. But i failed. Can you help me, please?
I am noob at perl and not familiar with that kind of drivers. What does mean
io
attribute? And why is my script freezes when i performing it? What i did wrong?