Out of the box database support

A

Alex Biddle

Hey there.

I was wondering whether Python had any support out-of-the-box for
database functionality, or database-like functionality.

For instance a lot of shared hosts have Python installed, but not the
MySQL extension, the flexible of these would install it, but most of
the time they wouldn't bother.

I was really looking for something like SQLite which ships bundled
with PHP these days. Or any standard way of connecting to generic
databases out of the box, i.e. MySQL.


Thanks for reading.
Alex Biddle.
 
A

Alex Martelli

Alex Biddle said:
Hey there.

I was wondering whether Python had any support out-of-the-box for
database functionality, or database-like functionality.

For instance a lot of shared hosts have Python installed, but not the
MySQL extension, the flexible of these would install it, but most of
the time they wouldn't bother.

I was really looking for something like SQLite which ships bundled
with PHP these days. Or any standard way of connecting to generic
databases out of the box, i.e. MySQL.

Python 2.5's standard library includes pysqlite. For any other DB, or
any previous release of Python, you need separate downloads.

Of course, shared hosts that are too lazy (and uninterested in
supporting Python) to perform a 20-seconds download and install, will
hardly be upgrading to Python 2.5 in the next 20 years or so, therefore
I doubt that pysqlite becoming part of the standard library is of any
help to the problem you have stated (in the "for instance" paragraph).


Alex
 
A

Alex Biddle

Ah, so separate downloads then. At least now I know.

Ergh... I checked the version of Python my current host is running and its 2.2.

....ergh....
 
A

Alex Biddle

Alex Biddle said:
Hey, thanks for the reply Jean-Paul.

That's pretty cool knowing that Python 2.5 will have it out of the
box, however what about basic out-of-the-box functionality in 2.4 (or
even older)?

In all my other experiences Python comes with a lot of tools already
available, it seems odd not to have basic database functionality
installed as default.

Would you like a pony with that? pysqlite *is* available today, and is not
overly onerous to install or bundle with your own package. And on the near
horizon, we see that it *will* be part of the included batteries, so
separate installation is only a temporary nuisance.

But there is another database battery available in current Python versions.
Try this:

import bsddb


No SQL support, instead this gives you a dict-like access to the database
(values must be strings, so you have to serialize columns into something
like XML, JSON, YAML, etc.):

import bsddb
db = bsddb.hashopen("testdb.db")
db["Paul"]="""<user name="Paul" id="12345"/>"""
db["Alex"]="""<user name="Alex" id="12346"/>"""
print db.keys()
del db["Paul"]
print db.keys()
db.close()


Thanks for the info. No thanks for the smarmy "pony" comment. I can't
install my own version because I'm on a shared server, of course
ideally I wouldn't like to be.


This is why you really want a VPS (virtual private server). The cost is
similar to a web host but you get to choose your own technologies and
versions. Several companies come to mind:

http://westhost.com/
http://jvds.com/
http://linode.com/

I'm using Westhost, which provides Python 2.2 if you ask for it, but I
compiled Python 2.4 instead. I didn't even have to ask whether I was
allowed to do that. :)

Shane

Yeah, ideally a VPS would be the way to go. In the US hosting seems to
be cheaper than here in the UK, I don't know why. If I was going to
make a Python web app then I would go VPS, nowadays though I just make
do with PHP.


I guess you looked here without finding what you want?

http://www.python.org/doc/topics/database/

What's the big deal with "out of the box"? People have different tastes
in dbs and ways to access them, why not just pick the one you want and
download it?

You didn't say if you are on Linux or Windows. The ODBC module comes
with PythonWin. Others have good luck with mxODBC, which works right
out of the box after you download and install it.

The big deal with "out of the box" is that if it had support from the
outset for MySQL then Python could appeal to the mass market of people
who go for cheap-o hosts that can't be bothered to upgrade Python let
alone install databasefoo support. Currently this market is more or
less solely occupied by PHP.

Yes... I have installed MySQL support etc. on my local Linux server
but I /can't/ do that on a shared hosting environment.
Searching the group will tell you all you need to know on this topic,
as it comes up twice a week.

For what it's worth, I did try searching, but I guess my parametres
were the wrong ones. If it comes up twice a week, perhaps its a case
of demand and supply anyway?
 
B

BartlebyScrivener

Thanks for the info. No thanks for the smarmy "pony" comment.

Do you really want "smarmy" here? I don't think it works. Don't you
mean "flip" or "smart-alecky" or "facetious"?

Websters 3rd Unabridged
Main Entry:smarmy
Function:adjective
Inflected Form:-er/-est

1 : SLEEK *smarmy-headed David Walker*
2 : unctuously or fulsomely flattering : SLOBBERY, GUSHING, OILY,
INSINUATING "young man with the smarmy voice"--Noel Coward; "coy and
smarmy"-- Bernard Hollowood; "smarmy insincerity" Eric Partridge; "a
smarmy little melody"--Time

rd
 
D

Dennis Lee Bieber

Thanks for the info. No thanks for the smarmy "pony" comment. I can't
install my own version because I'm on a shared server, of course
ideally I wouldn't like to be.
Well, if your provider had a more recent Python, you could probably
drop the files used by Python's SQLite builds directly into your CGI
directory, and add it to the python path in each CGI script. SQLite,
being a file-server DB rather than a client-server type only needs RW
access to the whatever database file you specify -- which could also
perhaps be in the CGI directory (unless your provider requires custom
upload procedures and sets things execute only once /it/ populates the
CGI directory).
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
T

Terry Hancock

BartlebyScrivener said:
Do you really want "smarmy" here? I don't think it works. Don't you
mean "flip" or "smart-alecky" or "facetious"?

Hmm. I think the word we're looking for here is "snarky". ;-)

Although, I confess to ignorance on what a "snark" is or whether
it is particularly known for brief self-consciously clever sarcastic
responses.

I sympathize with the shared-hosting problem, that's a major pain.
I would say 'go find a virtual private hosting service', but my
batting average is not so good with actual companies on that. I had
one that was pretty decent, but then went out of business and now
I'm with one that has rather poor-to-mediocre support and has been
extraordinarily slow ("VPSLand", BTW). I don't suppose anyone has
better options? I was looking for somebody that would let me run
Debian on a VPS.

Cheers,
Terry
 
A

Alex Martelli

BartlebyScrivener said:
Leave it to the guy who can quote Borges and The Celestial Emporium of
Benevolent Knowledge while explaining multiple inheritance.

See Cookbook 2nd Ed pg. 234

<bow>...;-)


Alex
 
A

Alex Biddle

Do you really want "smarmy" here? I don't think it works. Don't you
Hmm. I think the word we're looking for here is "snarky". ;-)

Although, I confess to ignorance on what a "snark" is or whether
it is particularly known for brief self-consciously clever sarcastic
responses.

I sympathize with the shared-hosting problem, that's a major pain.
I would say 'go find a virtual private hosting service', but my
batting average is not so good with actual companies on that. I had
one that was pretty decent, but then went out of business and now
I'm with one that has rather poor-to-mediocre support and has been
extraordinarily slow ("VPSLand", BTW). I don't suppose anyone has
better options? I was looking for somebody that would let me run
Debian on a VPS.

Cheers,
Terry

Thanks for the considerate reply, it is annoying being stuck on a
shared server.
Do you really want "smarmy" here? I don't think it works. Don't you
mean "flip" or "smart-alecky" or "facetious"?
From some Internet dictionary:
Smarmy:
1. Hypocritically, complacently, or effusively earnest; unctuous. See
Synonyms at unctuous.
2. Sleek.

I was aiming specifically towards the "effusively earnest" I don't
think that's a bad word to describe "would you like a pony with that
too?"

Anyway, the first time I read replies to my message I chuckled. It's
like the stereotypical intellectual debate, if you don't like the
message then focus on the detail.

The message in this case was that I /couldn't/ install anything by
myself as it is on a /shared/ server that's why I wanted to know
whether there was anything out of the box I could use.

Of course I would install all the "ponies" I wanted given I had proper
privileges to the machine.
 
F

Fredrik Lundh

Alex said:
The message in this case was that I /couldn't/ install anything by
myself as it is on a /shared/ server that's why I wanted to know
whether there was anything out of the box I could use.

but you did search the library reference TOC and/or the index for "database" before
you posted, and found that the "persistent dictionary" stuff in there weren't databasish
enough, right ?

</F>
 
A

Alex Biddle

Yes, I searched but couldn't find anything. Maybe I wasn't searching
for the right things / in the right places.

I admit I'm more used to forums than mailing lists, but I always make
some effort to search.
 
A

Aahz

I sympathize with the shared-hosting problem, that's a major pain. I
would say 'go find a virtual private hosting service', but my batting
average is not so good with actual companies on that. I had one that
was pretty decent, but then went out of business and now I'm with one
that has rather poor-to-mediocre support and has been extraordinarily
slow ("VPSLand", BTW). I don't suppose anyone has better options? I
was looking for somebody that would let me run Debian on a VPS.

http://www.panix.com/corp/virtuals/vservers.html

Unfortunately, it's not being as well advertised as it should be, but
Panix is definitely one of the class operators.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top