[bf1942] Database support in Py?

Forrest Thiessen thiessen at alum.mit.edu
Tue Jul 5 13:02:38 EDT 2005


Einar S. Idsø wrote:

>I just finished a Py-module based on SQLite. When I plugged it into BF2
>and started the server, I got the following jawdropper:
>
> ImportError:  No module named sqlite
>
>I then unpacked pylib-2.3.4.zip, and the only database library I was
>able to find is bsddb. I suppose this means that there is no way to use
>MySQL or SQLite directly from within BF2. Is this something which may
>change at a later time?
>
>The csv library also seems to be missing, so I suppose the only way to
>store data in any kind of DB-like manner is to use bsddb or tabulated
>ascii-files. Or is there a better way?
>  
>
I haven't tried it yet myself, but did you try installing the missing
modules/packages yourself? As long as the modules/packages you are
trying to import are located in one of the directories in sys.path, they
ought to work.

As a first step, you could just put the packages/modules you want into
the Battlefield 2 Server/python directory, since that directory is
already in sys.path.  Later, if you want to put them somewhere else, you
could add your new library directory to the end of sys.path.

pylib-2.3.4.zip is just the Python Standard Library; as far as I've
seen, there isn't anything special about it--it just includes the
standard stuff that's part of any Python distribution. . . which doesn't
include MySQL stuff.  The standard Python MySQL adaptor for Python is at:
    http://sourceforge.net/projects/mysql-python
(be sure you get the version for Python 2.3, which is what BF2 uses, not
2.4). This download contains several files and a package; depending on
which version you get, it will probably try to install it someplace
besides in the directory you want, but you can just move them where you
want them.

If I get a chance, I'll try playing with it later today or tomorrow.

--Forrest (aka "Woody")






More information about the Bf1942 mailing list