Export CSV from MySQL directly
If you need to export data from MySQL to a CSV, you can profit from really fast built-in methods.
This query writes the data to /tmp/geodb_coodinates.csv. And it's fast: Query OK, 337925 rows affected (0.86 sec)
SELECT * INTO OUTFILE '/tmp/geodb_coordinates.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' FROM geodb_coordinates;
Related cards:
Delete from joined MySQL tables
When you need to delete rows from a table, and the delete conditions require a joined table, MySQL needs to know which table you want to delete from.
Let's say that Post belongs_to :author
. In order to delete all posts from the author named "Er...
ActionMailer: How to send a test mail directly from the console
If your rails application is unable to send mails, it might be useful to debug your settings using the rails console. Here is a snippet that shows the current settings and lets you send a test mail directly from the console:
mailer = Acti...
MySQL: "LOAD DATA INFILE" says "file not found"
This might be due to AppArmor denying the MySQL server access to most of the filesystem. You can instead use
LOAD DATA LOCAL INFILE ...
to pipe data through the MySQL client, which can read everything the executing user can.
Open a MySQL shell using credentials from database.yml
In order to open a MySQL shell without the need to enter user and password, you can say the following in any Rails 2 project:
script/dbconsole -p
In Rails 3 you can say:
rails dbconsole -p
If you'd like to enter a database for an envir...
Directly search makandra notes from the Firefox address bar
The speed searching for makandra notes in Firefox can be improved by following these steps:
- Download the Firefox-Add-on ["Add to Search Bar"](https://web.archive.org/web/20181102012952/https://addons.mozilla.org/en-US/firefox/addon/add-to-sear...
Long cards: Directly jump from a paragraph to the same paragraph in the editor
If you hover over the text of a card, you will now see EDIT links at the top right corner of each block.
This link will open the card editor and scroll the editor to this very paragraph. The cursor caret will sit on the first character of that ...
Advisory: Excel converts CSV entries to formulas
If your application exports CSV, be advised that Excel and other spreadsheet applications treat certain cells (those starting with =
, +
, -
or @
) as formulas.
This is an issue if you output user input. Not only is it probably not what you...
Installing multiple MySQL versions on the same Linux with mysql-sandbox
Ubuntu has a package mysql-sandbox
that lets you install multiple MySQL versions into your user home:
- Install
mysql-sandbox
sudo apt install mysql-sandbox
- Download the version of MySQL you want to use from mysql.com:
<https://...
MySql lost connection trouble
Directly from the MySql docs:
There are three likely causes for this error message.
Usually it indicates network connectivity trouble and you should check the condition of your network if this error occurs frequently. If the error message includ...
Dumping and importing from/to MySQL in an UTF-8 safe way
In a nutshell: to avoid your shell character set from messing with imports, use -r
to export and SOURCE
when importing.
Dumping safely
# Do not do this, since it might screw up encoding
mysqldump -uroot -p database...