Error while Happybase connection with hbase, how I define my host - pyspark

I want to connect Pyspark with Hbase by Happybase. But I get this error at the beginnig:
(pyenv) hduser#master:~$ python -c 'import happybase'
(pyenv) hduser#master:~$ python -c connection = happybase.Connection("somehost")
bash: syntax error near unexpected token `('

First there is a syntax error in connection command. Secondly if you want to use the happybase library in subsequent steps, you have to run the entire script into single command from the bash in following way so that the session will be maintained.
python -c "import happybase;connection = happybase.Connection('localhost')"
Another option is create a python .py file and run that from the bash.

Related

I'm trying to import a SQL backup file but I keep getting an error

I'm trying to import a SQL backup file but I keep getting the error
todolist-# psql todolist < C:\Users\ojadi\Documents\todolist2.sql
invalid command \Users
Try \? for help.
todolist-#
That is a command you give in UNIX shell, not a command you give in psql. Since it seems you already have psql running, you can run the file using command
\i C:\Users\ojadi\Documents\todolist2.sql
Note that your prompt todolist-# indicates you are in the middle of writing a command in psql. See my answer to this earlier question

What could cause a ".json is unexpected at this time" error when running a postman collection from command line using newman

I am attempting to use newman to run postman collection from the command line. I have been successful before, but with this most recent collection I am getting an error. I am using the following command
newman run [urlforjcollection] --reporters cli,json,html --reporter-json-
export C:\outputfile.json --reporter-
html-export C:\outputfile.html -e
c:\QAEnvironment.json
This fails to run and I get the error .json was unexpected at this time. As I said I used this exact command on another collection and it worked fine.
Does anyone know what could case this issue? Is it something wrong with my command or is there some setting in postman that can cause it?
I Googled your error and it seems to be a problem with the command line rather than Postman; specifically, the need to use double quotes while specifying file locations. Try this:
newman run [urlforjcollection] --reporters cli,json,html --reporter-json-
export "C:\outputfile.json" --reporter-
html-export "C:\outputfile.html" -e
"c:\QAEnvironment.json"

run part of a script in IPython

I'd like to run part of a scritp (script.py) in IPython, up to line 90.
I have tried
%run -d -b90 script.py
as well as
%run -d -b 90 script.py
but I got the following message
I failed to find a valid line to set a breakpoint
after trying up to line: 100.
Please set a valid breakpoint manually with the -b option
How can I do this in the IPython console? there is always the possibility to use an external command and copy the lines I am interested in to another file and run that new script.
thanks

how to invoke unix command in perl

i am trying to execute following unix command but its not getting executed
$array_of_tables= `dbsmp $srv_name`;
print "$array_of_tables\n";
please help me to find out list of tables in a data base through perl scripting.
Also i am trying to copy a file from a path to different path by using following command:-
copy(`cd /osp/slee/service/$srv_name/bin/exec/script.txt`,`cd /osp/local/home/linus/amit/scripts`);
but getting an error:-
Usage: copy(FROM, TO [, BUFFERSIZE])
please provide some solution
Thanks
Use doublequotes instead of back ticks.
copy("/osp/slee/service/$srv_name/bin/exec/script.txt","/osp/local/home/linus/amit/scripts");
and remove the cd
In Perl, the preferable way to capture the output of a system (shell) command is the qx() operator. See http://perldoc.perl.org/perlop.html#Quote-Like-Operators.
$array_of_tables = qx(dbsmp $srv_name);
print("$array_of_tables\n");
Actually, backticks should also work, so the problem must lie with your dbsmp command. I'm not sure what that command is; you'll have to provide more information about the utility and what error you're seeing.
For comparison, I can retrieve the list of tables in my local postgres database as a pipe-separated table using this shell command:
> psql -tAXq main postgres <<<\\d;
And this can be run from Perl as follows:
> perl -e 'print(qx(psql -tAXq main postgres <<<\\\\d;));'

How to generate database diagrams from the command line in Fedora 19?

I'm new to Linux and have just installed Fedora 19 in VirtualBox.
I am running MariaDB and am wanting to generate database diagrams from the command line.
I have come across a few examples of output from SQLFairy:
http://nsaunders.wordpress.com/2009/01/11/easy-visualisation-of-database-schemas-using-sqlfairy/
http://www.christianbiggins.com/2008/11/er-diagrams-from-sql-files.html
http://techmania.wordpress.com/2008/06/09/creating-er-diagrams-from-sql/
And that seems to be the type of thing I am after.
I did a yum search with 'yum search sqlfairy' but there didn't seem to be any results.
Could anyone please tell me how to install sqlfairy in Fedora 19, or, if that's not possible, recommend a product that does a similar thing?
Edit:
I found this: https://admin.fedoraproject.org/pkgdb/acls/name/perl-SQL-Translator#f19
and installed via yum install perl-SQL-Translator.
I am now trying:
[me#my ~] sqlt-graph -f MySQL -o mydatabase.png -t png mydatabase.sql
but am getting error:
ERROR (line 36): Invalid statement: Was expecting comment,
or use, or set, or drop, or create, or alter, or insert, or
delimiter, or empty statement
Error: translate: Error with parser 'SQL::Translator::Parser::MySQL':
no results at /usr/bin/sqlt-graph line 195.
The .sql file is located is home/me which is where I am running the command from.
The solution was to follow the steps above, the error was solved by using the following for the mysqldump command, then the sqlt command above worked:
[username#hostname ~] mysqldump -u root -pmysql_root_password --no-data database_name > example.sql
Take a look at SchemaCrawler, which can generate database diagrams from the command line. It works on Linux, and needs Java installed. You will need to find a JDBC driver for MariaDB.
Sualeh Fatehi, SchemaCrawler