snipt

Ctrl+h for KB shortcuts

MySQL

Disable drupal securepages after importing db

UPDATE variable SET value = 's:1:"0";' WHERE name = 'securepages_enable';
https://snipt.net/embed/06dada149801ea162d92481a0bd62304/
https://snipt.net/raw/06dada149801ea162d92481a0bd62304/
06dada149801ea162d92481a0bd62304
mysql
MySQL
1
2016-09-26T22:36:08
True
False
False
Oct 18, 2013 at 06:31 AM
/api/public/snipt/88480/
disable-drupal-securepages-after-importing-db
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">UPDATE</span> <span class="n">variable</span> <span class="kt">SET</span> <span class="n">value</span> <span class="o">=</span> <span class="s1">&#39;s:1:&quot;0&quot;;&#39;</span> <span class="k">WHERE</span> <span class="n">name</span> <span class="o">=</span> <span class="s1">&#39;securepages_enable&#39;</span><span class="p">;</span> </span></pre></div> </td></tr></table>
db, drupal, mysql

MySQL

db - example of a left join on a concat

1
2
3
4
SELECT t.tid AS tid, ua.alias
FROM taxonomy_term_data t
LEFT JOIN url_alias ua ON ua.source LIKE CONCAT('taxonomy/term/', t.tid )
WHERE t.vid =2
https://snipt.net/embed/3b612d8bdca43fa04cb8aaefef3f7f29/
https://snipt.net/raw/3b612d8bdca43fa04cb8aaefef3f7f29/
3b612d8bdca43fa04cb8aaefef3f7f29
mysql
MySQL
4
2016-09-25T05:49:32
True
False
False
/api/public/snipt/88471/
db-example-of-a-left-join-on-a-concat
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">SELECT</span> <span class="n">t</span><span class="p">.</span><span class="n">tid</span> <span class="k">AS</span> <span class="n">tid</span><span class="p">,</span> <span class="n">ua</span><span class="p">.</span><span class="n">alias</span> </span><span id="L-2"><a name="L-2"></a><span class="k">FROM</span> <span class="n">taxonomy_term_data</span> <span class="n">t</span> </span><span id="L-3"><a name="L-3"></a><span class="k">LEFT</span> <span class="k">JOIN</span> <span class="n">url_alias</span> <span class="n">ua</span> <span class="k">ON</span> <span class="n">ua</span><span class="p">.</span><span class="n">source</span> <span class="k">LIKE</span> <span class="nf">CONCAT</span><span class="p">(</span><span class="s1">&#39;taxonomy/term/&#39;</span><span class="p">,</span> <span class="n">t</span><span class="p">.</span><span class="n">tid</span> <span class="p">)</span> </span><span id="L-4"><a name="L-4"></a><span class="k">WHERE</span> <span class="n">t</span><span class="p">.</span><span class="n">vid</span> <span class="o">=</span><span class="mi">2</span> </span></pre></div> </td></tr></table>
db, mysql

Ruby

Get current environment database configuration.

1
2
3
4
Rails.configuration.database_configuration[Rails.env]


=> {"encoding"=>"unicode", "username"=>"postgres", "adapter"=>"postgresql", "port"=>5432, "host"=>"localhost", "password"=>"postgres", "database"=>"mydb", "pool"=>5}
https://snipt.net/embed/1cc7c0a5f6940605863a6e551117f669/
https://snipt.net/raw/1cc7c0a5f6940605863a6e551117f669/
1cc7c0a5f6940605863a6e551117f669
rb
Ruby
4
2016-09-25T06:38:55
True
False
False
/api/public/snipt/28360/
get-current-environment-database-configuration
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="no">Rails</span><span class="o">.</span><span class="n">configuration</span><span class="o">.</span><span class="n">database_configuration</span><span class="o">[</span><span class="no">Rails</span><span class="o">.</span><span class="n">env</span><span class="o">]</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="o">=&gt;</span> <span class="p">{</span><span class="s2">&quot;encoding&quot;</span><span class="o">=&gt;</span><span class="s2">&quot;unicode&quot;</span><span class="p">,</span> <span class="s2">&quot;username&quot;</span><span class="o">=&gt;</span><span class="s2">&quot;postgres&quot;</span><span class="p">,</span> <span class="s2">&quot;adapter&quot;</span><span class="o">=&gt;</span><span class="s2">&quot;postgresql&quot;</span><span class="p">,</span> <span class="s2">&quot;port&quot;</span><span class="o">=&gt;</span><span class="mi">5432</span><span class="p">,</span> <span class="s2">&quot;host&quot;</span><span class="o">=&gt;</span><span class="s2">&quot;localhost&quot;</span><span class="p">,</span> <span class="s2">&quot;password&quot;</span><span class="o">=&gt;</span><span class="s2">&quot;postgres&quot;</span><span class="p">,</span> <span class="s2">&quot;database&quot;</span><span class="o">=&gt;</span><span class="s2">&quot;mydb&quot;</span><span class="p">,</span> <span class="s2">&quot;pool&quot;</span><span class="o">=&gt;</span><span class="mi">5</span><span class="p">}</span> </span></pre></div> </td></tr></table>
config, db, ruby

Bash

dump postgres schema

1
2
3
4
5
#dump postgres
su - postgres -c "/usr/bin/pg_dump dbname | gzip -c > /path/dbname.sql.gz"

#dump only schema
su - postgres -c "/usr/bin/pg_dump -s dbname | gzip -c > /path/dbname_schema.sql.gz"
https://snipt.net/embed/869683e174a385507555fd0ec84d98a0/
https://snipt.net/raw/869683e174a385507555fd0ec84d98a0/
869683e174a385507555fd0ec84d98a0
bash
Bash
5
2016-09-26T23:04:45
True
False
False
/api/public/snipt/27810/
dump-postgres-schema
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c">#dump postgres</span> </span><span id="L-2"><a name="L-2"></a>su - postgres -c <span class="s2">&quot;/usr/bin/pg_dump dbname | gzip -c &gt; /path/dbname.sql.gz&quot;</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c">#dump only schema</span> </span><span id="L-5"><a name="L-5"></a>su - postgres -c <span class="s2">&quot;/usr/bin/pg_dump -s dbname | gzip -c &gt; /path/dbname_schema.sql.gz&quot;</span> </span></pre></div> </td></tr></table>
backup, db, dump, postgres
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.