Re: Switching python app from sqlite to postgres

From: Monte Milanuk <memilanuk(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Switching python app from sqlite to postgres
Date: 2012-04-15 15:45:20
Message-ID: 4F8AED10.7040305@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 04/15/2012 06:17 AM, Bob McConnell wrote:
> sqlite is not included in either version of Python I have installed
> (2.5.2 and 3.1.1). I tried installing it after doing the parallel
> installation of 3.1.1, but it bound to the older version of Python. I
> don't know anything about either Python or sqlite, so I have no idea how
> to get them to work together.

I would almost bet money that your python installs *do* have sqlite
built-in and available. Even distributions such as Ubuntu Linux which
tends to break up the base install of python a bit so as to not require
thinks like tkinter (normally also 'built-in' to python) for server
installs, include sqlite by default. My understanding is that it
(sqlite) is used for a lot of small data stores when something slightly
more than a pickle or shelve is needed.

Fire up the python interpreter of your choice, and type 'import sqlite3'
like so:

monte(at)hp-dv4-linux:~$ python
Python 2.7.2+ (default, Oct 4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.7.7'
>>> quit()
monte(at)hp-dv4-linux:~$ python3
Python 3.2.2 (default, Sep 5 2011, 21:17:14)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.7.7'
>>> quit()
monte(at)hp-dv4-linux:~$

Simple enough to test on your own. You can follow along a simple
tutorial from here if you like:

http://zetcode.com/db/sqlitepythontutorial/

BTW, that site has a lot of good tutorials... including one on Python +
PostgreSQL...

http://zetcode.com/db/postgresqlpythontutorial/

HTH,

Monte

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bob McConnell 2012-04-15 19:28:45 Re: Switching python app from sqlite to postgres
Previous Message Bob McConnell 2012-04-15 13:17:32 Re: Switching python app from sqlite to postgres