Popular recipes tagged "sql" but not "python"http://code.activestate.com/recipes/tags/sql-python/2015-02-24T22:08:11-08:00ActiveState Code RecipesPublish SQLite data to PDF using named tuples (Python) 2015-02-24T22:08:11-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/579027-publish-sqlite-data-to-pdf-using-named-tuples/ <p style="color: grey"> Python recipe 579027 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/conversion/">conversion</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/sql/">sql</a>, <a href="/recipes/tags/sqlite/">sqlite</a>, <a href="/recipes/tags/sqlite3/">sqlite3</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>This recipe shows how to publish SQLite data to PDF, using named tuples from the collections module of Python, the sqlite3 library, and the xtopdf library for PDF generation.</p> Printing list of ODBC data sources with pyodbc module (Python) 2014-01-28T10:40:56-08:00Michal Niklashttp://code.activestate.com/recipes/users/186902/http://code.activestate.com/recipes/578815-printing-list-of-odbc-data-sources-with-pyodbc-mod/ <p style="color: grey"> Python recipe 578815 by <a href="/recipes/users/186902/">Michal Niklas</a> (<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/odbc/">odbc</a>, <a href="/recipes/tags/sql/">sql</a>). </p> <p>I have similar recipe but with <code>odbc</code> module: <a href="http://code.activestate.com/recipes/578782-printing-list-of-odbc-data-sources/" rel="nofollow">http://code.activestate.com/recipes/578782-printing-list-of-odbc-data-sources/</a></p> Printing list of ODBC data sources (Python) 2013-12-10T11:07:37-08:00Michal Niklashttp://code.activestate.com/recipes/users/186902/http://code.activestate.com/recipes/578782-printing-list-of-odbc-data-sources/ <p style="color: grey"> Python recipe 578782 by <a href="/recipes/users/186902/">Michal Niklas</a> (<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/odbc/">odbc</a>, <a href="/recipes/tags/sql/">sql</a>). </p> <p>This simple code shows ODBC data sources. It uses <code>odbc</code> module.</p> sql+ the SQL*Plus killer (Python) 2013-03-14T09:13:01-07:00johttp://code.activestate.com/recipes/users/4185610/http://code.activestate.com/recipes/578490-sql-the-sqlplus-killer/ <p style="color: grey"> Python recipe 578490 by <a href="/recipes/users/4185610/">jo</a> (<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/db/">db</a>, <a href="/recipes/tags/db_client/">db_client</a>, <a href="/recipes/tags/sql/">sql</a>, <a href="/recipes/tags/sql_client/">sql_client</a>). Revision 3. </p> <p>This recipe is an emulator of the Oracle SQL*Plus, but it does things in a more friendly way ;).</p> <p>If you need a client to access your Oracle but you don't like SQL*Plus, try this one.</p> <p>This recipe was inspired by James Thiele's Console built with Cmd object recipe.</p> <p>It provides a 'help' facility and supplies command completion when you hit the 'tab' key.</p> <p>In addition you can use command line editing and history keys.</p> <p>Here are the commands that you can use:</p> <pre class="prettyprint"><code>======================================== Documented commands (type help &lt;topic&gt;): ======================================== constraints edit help input sequences shell db exit history output set tables desc foreigns index quit settings triggers </code></pre> <p>You can edit the queries using 'vim' or any other editor.</p> <p>The command 'output' can redirect output to a file and command 'input' can input commands from a file.</p> <p>There's paginated output.</p> <p>The command 'shell' or '!' allow you to perform operating system commands.</p> <p>You can add commands by defining methods with names of the form 'do_xxx()' where 'xxx' is the name of the command you wish to add.</p> <p>There is a configuration file (.sql+) where you need to enter the dburi, editor name and other settings.</p> Inner Join (Python) 2011-11-01T20:10:34-07:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/577937-inner-join/ <p style="color: grey"> Python recipe 577937 by <a href="/recipes/users/178123/">Raymond Hettinger</a> (<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/join/">join</a>, <a href="/recipes/tags/sql/">sql</a>). Revision 2. </p> <p>Implemented an SQL style INNER JOIN for two lists of tuples to be joined on a common field.</p> Conjunction select using foreign keys (Text) 2011-06-11T02:43:22-07:00Kaushik Ghosehttp://code.activestate.com/recipes/users/4166965/http://code.activestate.com/recipes/577747-conjunction-select-using-foreign-keys/ <p style="color: grey"> Text recipe 577747 by <a href="/recipes/users/4166965/">Kaushik Ghose</a> (<a href="/recipes/tags/conjunction/">conjunction</a>, <a href="/recipes/tags/foreign/">foreign</a>, <a href="/recipes/tags/key/">key</a>, <a href="/recipes/tags/select/">select</a>, <a href="/recipes/tags/sql/">sql</a>). </p> <p>Say we have a table (notes) containing rows we want to select. Each note has one or more keywords (stored in a table of the same name). We want to select notes that have a conjunction of keywords (AND). notes and keywords are linked through a foreign key table notes_keywords. The following SQL statement allows us to do this</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> Minimalistic PostgreSQL console shell (Python) 2011-11-30T13:43:28-08:00ccpizzahttp://code.activestate.com/recipes/users/4170754/http://code.activestate.com/recipes/577468-minimalistic-postgresql-console-shell/ <p style="color: grey"> Python recipe 577468 by <a href="/recipes/users/4170754/">ccpizza</a> (<a href="/recipes/tags/postgres/">postgres</a>, <a href="/recipes/tags/postgresql/">postgresql</a>, <a href="/recipes/tags/sql/">sql</a>). Revision 17. </p> <p>Primitive shell for running PostgreSQL quieries from console. Make sure you set the right connection settings in the script.</p> <p>All queries are executed in autocommit mode.</p> <p>Example command line usage:</p> <pre class="prettyprint"><code>pg.py select * from mytable where oidh=1 </code></pre> <p>The script recognizes a number of magic keywords:</p> <pre class="prettyprint"><code>pg.py show databases pg.py show schemas pg.py describe &lt;table_name&gt; </code></pre> ExecSql.cgi returning JSON for SQL (Python) 2009-11-28T02:00:30-08:00Martchenkohttp://code.activestate.com/recipes/users/4172446/http://code.activestate.com/recipes/576971-execsqlcgi-returning-json-for-sql/ <p style="color: grey"> Python recipe 576971 by <a href="/recipes/users/4172446/">Martchenko</a> (<a href="/recipes/tags/cgi/">cgi</a>, <a href="/recipes/tags/json/">json</a>, <a href="/recipes/tags/sql/">sql</a>). </p> <p>CGI script getting JSON for SQL request</p> Transparently execute SQL queries as prepared statements with Postgresql (Python) 2009-03-23T07:30:07-07:00Michael Palmerhttp://code.activestate.com/recipes/users/1827292/http://code.activestate.com/recipes/576698-transparently-execute-sql-queries-as-prepared-stat/ <p style="color: grey"> Python recipe 576698 by <a href="/recipes/users/1827292/">Michael Palmer</a> (<a href="/recipes/tags/postgresql/">postgresql</a>, <a href="/recipes/tags/prepared_statements/">prepared_statements</a>, <a href="/recipes/tags/sql/">sql</a>). Revision 4. </p> <p>This recipe defines a mixin class for DBAPI cursors that gives them an 'executeps' method. This method transparently converts any SQL query into a prepared statement, which gets cached and executed instead of the original query.</p>