Popular recipes tagged "database" but not "python"http://code.activestate.com/recipes/tags/database-python/2016-09-18T20:39:20-07:00ActiveState Code RecipesDBF reader and writer -- selective fields and nullreplace (Python)
2016-09-18T20:39:20-07:00Tomas Nordinhttp://code.activestate.com/recipes/users/4189558/http://code.activestate.com/recipes/580696-dbf-reader-and-writer-selective-fields-and-nullrep/
<p style="color: grey">
Python
recipe 580696
by <a href="/recipes/users/4189558/">Tomas Nordin</a>
(<a href="/recipes/tags/database/">database</a>).
</p>
<p>This fork assumes a desire for limited selection of field names. With
huge files this might be necessary on some machines.</p>
<p>Also, assuming that the meaning of null in a dbf file means zero might
be a mistake, so the fork adds an argument nullreplace as way to
choose what to replace null with. Null is sometimes used to mean
missing value. This change is decoupled from the selective names
feature.</p>
Python ADO Database Interface for MS SQL Server - Python 3 version 1.0 (Python)
2014-08-27T16:04:04-07:00Jorge Besadahttp://code.activestate.com/recipes/users/100038/http://code.activestate.com/recipes/578913-python-ado-database-interface-for-ms-sql-server-py/
<p style="color: grey">
Python
recipe 578913
by <a href="/recipes/users/100038/">Jorge Besada</a>
(<a href="/recipes/tags/ado/">ado</a>, <a href="/recipes/tags/database/">database</a>).
Revision 3.
</p>
<p>This DBI implements the Cursor and Connection objects. You can create connections, cursors, do fetchone, fetchall. It uses ADO. Will add more features later </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>
Python Database Interface for MS SQL Server - Python 3 version (Python)
2014-07-11T19:25:48-07:00Jorge Besadahttp://code.activestate.com/recipes/users/100038/http://code.activestate.com/recipes/578906-python-database-interface-for-ms-sql-server-python/
<p style="color: grey">
Python
recipe 578906
by <a href="/recipes/users/100038/">Jorge Besada</a>
(<a href="/recipes/tags/database/">database</a>).
</p>
<p>This DBI implements the Cursor and Connection objects. It is functional: you can create connections, cursors, do fetchone, fetchall, get rowcount, etc. It uses osql or sqlcmd instead of ODBC or ADO. There is a good sized section with examples to get you started. </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>
A Phone Book GUI Built in wxPython Connected To Database Using Data Grid View (Python)
2013-09-29T19:25:23-07:00toufic zaarourhttp://code.activestate.com/recipes/users/4187866/http://code.activestate.com/recipes/578676-a-phone-book-gui-built-in-wxpython-connected-to-da/
<p style="color: grey">
Python
recipe 578676
by <a href="/recipes/users/4187866/">toufic zaarour</a>
(<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/datagridview/">datagridview</a>, <a href="/recipes/tags/graphical/">graphical</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/interface/">interface</a>).
</p>
<p>this GUI as simple as it is explains some basic but important graphical database interfacing; "Add", "Edit","Delete","Search" and few others along with a data grid view. in order to work create an sqlite3 database as follows:</p>
<p>data table : Phone,
column 1 : ID,
column 2 : name,
column 3 : surname,
column 4 : telephone.</p>
<p>save the sqlite3 file as file.db in a folder called Data and place it in the same directory as your python script.</p>
<p>if you want to create the sqlite3 database graphically use my previous post : <a href="http://code.activestate.com/recipes/578665-a-wxpython-gui-to-create-sqlite3-databases/" rel="nofollow">http://code.activestate.com/recipes/578665-a-wxpython-gui-to-create-sqlite3-databases/</a></p>
<p>Also there is more: I did not use auto-number for 'id' because I also wanted to include in the code a renumbering script.</p>
<p>I am pleased to receive all the suggestions and improvements on this site or to my e-mail directly if this is convenient to you.</p>
<p>note: if you don't like the database table name, and columns name create your own but make sure to change them in the code as well! in the end life is great! remember that!</p>
List MySql databases in a Gtk.TreeView (Python)
2013-11-27T14:03:21-08:00Anonimistahttp://code.activestate.com/recipes/users/4188571/http://code.activestate.com/recipes/578774-list-mysql-databases-in-a-gtktreeview/
<p style="color: grey">
Python
recipe 578774
by <a href="/recipes/users/4188571/">Anonimista</a>
(<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/gtk/">gtk</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/mysqldb/">mysqldb</a>, <a href="/recipes/tags/user_interface/">user_interface</a>).
</p>
<p>List MySql databases in a Gtk.TreeView</p>
Save and restore SHA-512 internal state (Python)
2013-03-03T18:05:42-08:00Dima Tisnekhttp://code.activestate.com/recipes/users/4068698/http://code.activestate.com/recipes/578479-save-and-restore-sha-512-internal-state/
<p style="color: grey">
Python
recipe 578479
by <a href="/recipes/users/4068698/">Dima Tisnek</a>
(<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/inner/">inner</a>, <a href="/recipes/tags/pickle/">pickle</a>, <a href="/recipes/tags/restore/">restore</a>, <a href="/recipes/tags/sha512/">sha512</a>, <a href="/recipes/tags/state/">state</a>).
</p>
<p>If you have a very long input to hash, you may want to save your progress.</p>
<p>CPython doesn't normally let you, but it's easy to hack around via ctypes</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 <topic>):
========================================
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>
Profile Manager (Cave Story) (Python)
2012-12-07T01:21:04-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578368-profile-manager-cave-story/
<p style="color: grey">
Python
recipe 578368
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/manager/">manager</a>, <a href="/recipes/tags/profile/">profile</a>).
</p>
<p>If you have ever played a game that only had one save slot and wanted to be able to manage profiles, the following code written for Cave Story may be of use to you. The recipe provides a starting point for how one might go about writing a profile manager for such a program that runs through a command interface.</p>
Saving snippets to SQLite3 database (Python)
2014-07-30T07:23:36-07:00p@ntut$http://code.activestate.com/recipes/users/4183895/http://code.activestate.com/recipes/578285-saving-snippets-to-sqlite3-database/
<p style="color: grey">
Python
recipe 578285
by <a href="/recipes/users/4183895/">p@ntut$</a>
(<a href="/recipes/tags/database/">database</a>).
Revision 5.
</p>
<p>Save your snippets/codes to sqlite3 database, search, edit, and delete.</p>
Read tabular data from Excel spreadsheets the fast and easy way (Python)
2012-10-09T07:00:55-07:00wei.Liuhttp://code.activestate.com/recipes/users/4183853/http://code.activestate.com/recipes/578283-read-tabular-data-from-excel-spreadsheets-the-fast/
<p style="color: grey">
Python
recipe 578283
by <a href="/recipes/users/4183853/">wei.Liu</a>
(<a href="/recipes/tags/database/">database</a>).
</p>
<p>Sometimes you get an Excel spreadsheet (say, from the marketing departement) and you want to read tabular data from it (i.e. a line with column headers and lines of data). There are many ways to do this (including ODBC + mxODBC), but the easiest way I've found is this one : provide a file name and a sheet name, and read the data !</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>
Simple Knowlegde Database (Python)
2012-01-05T08:58:40-08:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/577975-simple-knowlegde-database/
<p style="color: grey">
Python
recipe 577975
by <a href="/recipes/users/4174477/">Thomas Lehmann</a>
(<a href="/recipes/tags/antagonisms/">antagonisms</a>, <a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/knowledge/">knowledge</a>, <a href="/recipes/tags/opposites/">opposites</a>, <a href="/recipes/tags/relationships/">relationships</a>).
Revision 2.
</p>
<p><strong>What's the idea?</strong></p>
<ul>
<li>The idea is to be able to ask more successful questions than data provided.</li>
<li>To have a kind of simple database</li>
</ul>
<p><strong>How is this done?</strong></p>
<ul>
<li>A releationship is always though as a from of older/younger or bigger/smaller. You have to define those opposite meanings by calling 'defineAntagonism'</li>
<li>After this you can define a relationship by calling 'defineRelationship' using one of the opposite meanings and two ... I say names (can be persons or objects)</li>
<li>When you define that somebody/someting is bigger than somebody/something else then you implicitly provide two information (bigger <-> smaller)</li>
<li>Also when defining - more commonly explained - that A > B and B > C then also A > C and C < A. </li>
<li>That's the main logic implemented by this python code.</li>
</ul>
<p><strong>Special notes</strong></p>
<ul>
<li>We have to avoid inconsistent data; when it is defined that A > B then you are not allowed to say that B > A.</li>
<li>We have to sort relations because they build up - I name it like this - a dependency chain. When a query checks for A > C but A > B and B > C is defined only we need an order for searching.</li>
</ul>
Simple 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>
Rudimentary Database Engine (Python)
2013-09-02T01:51:53-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577825-rudimentary-database-engine/
<p style="color: grey">
Python
recipe 577825
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/engine/">engine</a>, <a href="/recipes/tags/example/">example</a>, <a href="/recipes/tags/experiment/">experiment</a>).
Revision 2.
</p>
<p>This module was written for self-academic purposes in an attempt to understand databases better. Just as in college where students are required to reinvent "wheels" like linked lists, trees, binary searches, et cetera, developing this program helped me understand some of the things that goes on behind the scenes in a database while also helping to learn what the desired output of each operation should be. The code in this module provides support for running a simple database engine that runs completely in memory and allows usage of various concepts available in a structured query language to get and set data that may be saved to file.</p>
Multiprocessing import wrapper (Python)
2011-08-23T22:11:42-07:00Matt Keranenhttp://code.activestate.com/recipes/users/38288/http://code.activestate.com/recipes/577856-multiprocessing-import-wrapper/
<p style="color: grey">
Python
recipe 577856
by <a href="/recipes/users/38288/">Matt Keranen</a>
(<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/etl/">etl</a>, <a href="/recipes/tags/import/">import</a>, <a href="/recipes/tags/multiprocessing/">multiprocessing</a>).
Revision 2.
</p>
<p>A script used to launch multiple import scripts using the multiprocessing module. Developed to parallelize loading of multiple log files into a database for aggregate analysis</p>
Export Oracle Database to CSV using cx_Oracle (Python)
2010-07-11T19:49:42-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577304-export-oracle-database-to-csv-using-cx_oracle/
<p style="color: grey">
Python
recipe 577304
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/csv/">csv</a>, <a href="/recipes/tags/database/">database</a>).
</p>
<p>Creates a CSV file for each table in the target Oracle database.</p>
Simple numeric database (Python)
2011-05-16T08:41:46-07:00Mike Sweeneyhttp://code.activestate.com/recipes/users/4177990/http://code.activestate.com/recipes/577697-simple-numeric-database/
<p style="color: grey">
Python
recipe 577697
by <a href="/recipes/users/4177990/">Mike Sweeney</a>
(<a href="/recipes/tags/array/">array</a>, <a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/numeric/">numeric</a>).
Revision 2.
</p>
<p>A simple in-memory numeric database for Python. Arrays are used to minimise memory consumption.</p>
Simple numeric database (Python)
2011-05-16T12:11:24-07:00Hamidreza Joshaghanihttp://code.activestate.com/recipes/users/4177804/http://code.activestate.com/recipes/577698-simple-numeric-database/
<p style="color: grey">
Python
recipe 577698
by <a href="/recipes/users/4177804/">Hamidreza Joshaghani</a>
(<a href="/recipes/tags/array/">array</a>, <a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/numeric/">numeric</a>).
</p>
<p>A simple in-memory numeric database for Python. Arrays are used to minimise memory consumption.</p>