Latest recipes tagged "mysql"http://code.activestate.com/recipes/tags/mysql/new/2016-02-11T17:31:39-08:00ActiveState Code RecipesSimple curses based MySQL 'top' (Python)
2011-11-02T20:28:48-07:00Mike 'Fuzzy' Partinhttp://code.activestate.com/recipes/users/4179778/http://code.activestate.com/recipes/577936-simple-curses-based-mysql-top/
<p style="color: grey">
Python
recipe 577936
by <a href="/recipes/users/4179778/">Mike 'Fuzzy' Partin</a>
(<a href="/recipes/tags/curses/">curses</a>, <a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/mysql/">mysql</a>, <a href="/recipes/tags/time/">time</a>).
Revision 3.
</p>
<p>This is little more than a modification of my previous recipe, however, I found it useful so I thought I would post it in the hopes that someone else would as well. There is color (BOLD white really) designation for 'Query' states vs others like 'Sleep'. </p>
A MSSQL XML importer for MySQL (Python)
2011-03-09T03:46:49-08:00Albert Perrien IIhttp://code.activestate.com/recipes/users/4177266/http://code.activestate.com/recipes/577601-a-mssql-xml-importer-for-mysql/
<p style="color: grey">
Python
recipe 577601
by <a href="/recipes/users/4177266/">Albert Perrien II</a>
(<a href="/recipes/tags/mysql/">mysql</a>, <a href="/recipes/tags/server/">server</a>, <a href="/recipes/tags/sql/">sql</a>, <a href="/recipes/tags/xml/">xml</a>).
</p>
<p>This is a simple function that takes records exported to XML from SQL Server or Access and imports them into MySQL. </p>
Plot database table dependecies for a mySQL database (Python)
2010-07-10T08:14:09-07:00Noufal Ibrahimhttp://code.activestate.com/recipes/users/4173873/http://code.activestate.com/recipes/577298-plot-database-table-dependecies-for-a-mysql-databa/
<p style="color: grey">
Python
recipe 577298
by <a href="/recipes/users/4173873/">Noufal Ibrahim</a>
(<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/dot/">dot</a>, <a href="/recipes/tags/graphs/">graphs</a>, <a href="/recipes/tags/graphviz/">graphviz</a>, <a href="/recipes/tags/mysql/">mysql</a>).
</p>
<p>The following snippet will output a spec suitable for the graphviz dot program. It will go through the database specified and for all the tables that start with any of the names in <code>table_prefixes</code>, it will create a dependency graph. A dependency in this context is when a field of one table has a foreign key reference to another. The edges are labelled with the actual field names. </p>
<p>It can be used like this</p>
<pre class="prettyprint"><code>python deps.py | dot -Tpng | display
</code></pre>
<p>This requires the InnoDB engine (i.e. something that honours foreign keys. MyISAM doesn't do so).</p>
Purge Mysql binary logs (Python)
2010-01-12T15:14:10-08:00Umang Gopanihttp://code.activestate.com/recipes/users/4172787/http://code.activestate.com/recipes/577004-purge-mysql-binary-logs/
<p style="color: grey">
Python
recipe 577004
by <a href="/recipes/users/4172787/">Umang Gopani</a>
(<a href="/recipes/tags/automate/">automate</a>, <a href="/recipes/tags/binary_logs/">binary_logs</a>, <a href="/recipes/tags/master_slave/">master_slave</a>, <a href="/recipes/tags/mysql/">mysql</a>, <a href="/recipes/tags/purge/">purge</a>).
Revision 8.
</p>
<p>Being a MySQL DBA , one faces a common issue in replication environment -> Disk space issue on master, since the number of binary logs have increased.
Now, one of the solution to this would be using expire_logs_days parameter in your mysql config file.
But what if, the slave is lagging by few hours or if the slave is broken since few days and the binary logs are removed due to the parameter set. Whenever the salve comes up, it will go bonkers, knowing that the binary log where it last stopped no more exists.</p>
<p>I faced this issue a couple of time until I decided to automate it using a script. Herewith I am attaching a python script which can run regularly in cron.</p>
Compare MySQL DB (Python)
2016-02-11T17:31:39-08:00Jice Clavierhttp://code.activestate.com/recipes/users/4089467/http://code.activestate.com/recipes/576589-compare-mysql-db/
<p style="color: grey">
Python
recipe 576589
by <a href="/recipes/users/4089467/">Jice Clavier</a>
(<a href="/recipes/tags/compare/">compare</a>, <a href="/recipes/tags/comparison/">comparison</a>, <a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/mysql/">mysql</a>).
Revision 3.
</p>
<p>Small module to and check for differences between 2 DB.</p>
<p>It will compare the table list, the tables structure and their content.</p>
<p>When you run the program, you are ask if you want a detailed comparison.
As global comparison will list all the different tables, detailed comparison will output
every different record (and will take longer to run)</p>
Converting MySQL database to an Amazon Simple DB database (Python)
2008-10-31T11:55:16-07:00Chris McAvoyhttp://code.activestate.com/recipes/users/4167739/http://code.activestate.com/recipes/576548-converting-mysql-database-to-an-amazon-simple-db-d/
<p style="color: grey">
Python
recipe 576548
by <a href="/recipes/users/4167739/">Chris McAvoy</a>
(<a href="/recipes/tags/amazon/">amazon</a>, <a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/mysql/">mysql</a>, <a href="/recipes/tags/simpledb/">simpledb</a>).
</p>
<p>This script will take all the tables from a given MySQL database and upload them to Amazon SimpleDB as Domains. The 'name' of each uploaded record is the value of the first primary key found in the table.</p>
<p>This was written to scratch a particular itch, I've tested it against a 500mb database of my own, but didn't try overly hard to make it an all purpose general tool.</p>
Converting MySQL queries to XML (PHP)
2008-09-11T13:16:40-07:00sameer boratehttp://code.activestate.com/recipes/users/4167072/http://code.activestate.com/recipes/576499-converting-mysql-queries-to-xml/
<p style="color: grey">
PHP
recipe 576499
by <a href="/recipes/users/4167072/">sameer borate</a>
(<a href="/recipes/tags/mysql/">mysql</a>, <a href="/recipes/tags/php/">php</a>, <a href="/recipes/tags/xml/">xml</a>).
</p>
<p>Converting MySQL queries to XML</p>