mysql
Django dump & restore database
# dump data to send to receiving host
./manage.py dumpdata > fixtures/all.json
# in mysql on receiving host
mysql -uUSER -pPASS DATABASE_NAME;
drop database DATABASE_NAME;
create database DATABASE_NAME;
exit;
# @ shell on receiving host
./manage.py syncdb
# in mysql on receiving host
mysql -uUSER -pPASS DATABASE_NAME;
delete from auth_permission; delete from django_admin_log; delete from django_content_type;
# @ shell on receiving host
./manage.py loaddata fixtures/all.jsonSphinx.conf for fast-searching tatoeba
Here's my first stab at it:
On ubuntu, after installing Sphinx from the repositories with
sudo apt-get install sphinxsearchThis file needs to be created at /etc/sphinxsearch/sphinx.conf
#
# Minimal Sphinx configuration sample for Tatoeba
#
source src1
{
type = mysql
sql_host = localhost
sql_user = MY_DB_USER
sql_pass = MY_DB_PASS
sql_db = MY_DB_NAME
sql_port = 3306 # optional, default is 3306
sql_query = \
SELECT id, sentence, lang \
FROM sentences
importing 500k free sentences from Tatoeba csvs into mysql
UPDATE ---------
As pointed out in the Tatoeba wall, an expidiated way of doing the import would be using this format:
mysqlimport --local -c id,lang,text -u user -p sentences sentences.csvEND UPDATE -----------
It's actually a lot easier than you'd think. Just create two tables in a mysql database, and load the csv into it.
# download the csvs
wget http://tatoeba.org/files/downloads/links.csv
wget http://tatoeba.org/files/downloads/sentences.csv
# login to mysql
mysql -uroot -pNow, at a mysql shell - the rest is easy:
replace first character of mysql string
To replace a question mark with a blank string:
UPDATE node SET title = CONCAT('', TRIM(LEADING '?' FROM title)) WHERE title LIKE '?%';
mysql to list cache and content tables for drupal
select table_name from information_schema.tables where table_schema='DB_NAME' and table_name like 'content%' or table_name like 'cache%';