Is it risky to use drush command in your custom module? - drupal

I want to run SQL query using drush sqlq command in my custom module and want to export data in a csv file.
drush sqlq “select nid, title from node_field_data” > test.csv
This is working fine but is it risky to use on live project? Or can it be a security vulnerability?
Please suggest.

Related

Create a Drupal 8 profile installer with a config export

I want to create a Drupal 8 profile installer with a config export, to export regulary my config to push data modifications in git.
I tried this tutorial: https://www.valuebound.com/resources/blog/how-to-create-installation-profile-in-Drupal8
but it dont worked.
And i exported the configuration with drupal config:export –remove-uuid --remove-config-hash
see drush drush config-export and Sync
https://www.drupal.org/docs/8/configuration-management/changing-the-storage-location-of-the-sync-directory
then when you make config changes run drush cex for commit the changes.
when updated form git you need to run drush cmi for imports the config
to watch out for you want to make sure your site uuids match: aka
drush cget system.site uuid
drush cset system.site uuid

SQLite3 one-line command for exporting table to the .sql file

In my rails application, I need to export an existing table as .sql file with one-line command ideally
Does anyone have an idea how to do it?
This dumps hole database
db_file = 'db/development.sqlite3'
sh("sqlite3 #{db_file} saraksts > from_file/test.sql")
sqlite3 database.db ".dump table_name"
should do it.

How to recover an overwritten directory in cloudera

I was using HIVE in my Cloudera VM.
I used the below command to write my output of my HQL statement to an output file.
`INSERT OVERWRITE LOCAL DIRECTORY '/home/cloudera/output'
SELECT * from City; ....`
After getting the output i found that all my files in the cloudera directory got over written. i can see only my output file in the path.
Is there any way i can undo or recover all the files that i've lost.
My hive.log file is below for any reference
You can try to search into hive trash folder (/user/hive/.Trash). I think that you will find your lost file.

How do I update a drupal module without deleting it first?

How do I upload a new version of a module to my site? If I choose "Install new module" through the administration page I get a message that the module already is installed. There are two work arounds that I have found, but none of them seems ideal and the way you are supposed to do it.
I can delete the old module first, and then upload and install the new version. However, if the modules has data associated with it, then this data will be lost.
I can replace the module files on the server. This doesn't seem such a clean way to do it, I would rather follow a more standard process, if there is any.
So what is the best way to do it?
Thanks!
Make a back-up...just in case.
Put your site in maintance mode.
Overwrite your module files with updated version (delete old module files first)
run /update.php from browser or from console run drush updb if you have drush installed (to make database changes if any and similar stuff).
Put your site in "normal" mode again...check if everything is ok.
https://www.drupal.org/node/250790
MilanG's answer is incorrect on step 3. You don't overwrite, you need to remove the existing modules files, then put the new module files in it's place. This is because new module releases may include removed files, and sometimes if those files aren't removed you have problems.
So...
Make a backup (drush site-archive)
Put site in maintenance mode (drush vset maintenance_mode 0)
Delete the old module's directory entirely (rm -fr path/to/modulename)
Download the latest version of the module (drush dl modulename)
Run update.php (drush -y updb)
Turn off maintenance mode (drush vset maintenance_mode 1)
With drush it's pretty easy to just write a wrapper script and run that by module, so that you could do "drush update-module modulename" and those other steps happen.

Drush generates .make file on server but it is not in the working directory?

I am a Drupal newbie and trying to clone my site which is hosted on an Aegir server (using BOA). I ran 'Drupal generate-makefile' command in the working directory (the directory in which site is located) and the file did get generated - but it is not in the working directory. I also tried forcing a path using 'Drupal make-generate path/to/store/makefile/makefilename' but the command ran and ended with an error 'call to an undefined function drush_make_error()'. Any ideas where the file may be getting generated? Also, any tips on how I can force a path for .make file would be really helpful!
Maybe it depends on your Drush version, but with Drush 5.x the makefile is sent to stout.
This is how I use make-generate if I want my makefile written in /root/:
drush make-generate -r /path/of/my/drupal/installation > /root/drupal-org.make

Resources