Need to access SQLite3 database file but have no definitions for tables

53 views
Skip to first unread message

Spencer Underwood

unread,
Apr 19, 2014, 2:26:20 PM4/19/14
to web...@googlegroups.com
I'm pretty new to web development as a whole and am planning to make a website for people playing the game EVE Online to use but have encountered some difficulty trying to access the database dump that CCP Games has released. The database dump is available here in a SQLite, MySQL and PostGres. I use Win7 with minimal rights so if I have to use MySQL or PostGres to fix this problem it has to be able to install and run without admin rights.

When accessing the database in the sqlite3 executable everything work perfectly, all that's needed to load the file is a .open sqlite-latest.sqlite and it just works. When opening the database file using the web2py DAL, it appears to load the file properly but doesn't know of any the tables that exist. This appears to be working as intended, but is a problem I can't figure out how to solve. When I try to manually define one of the tables I know exists (list of existing tables found here), I receive the error: sqlite3.OperationError: table invTypes already exists. The code I used to do this is as follows:

from os.path import join, exists
from httplib import HTTPException
from gluon.sql import DAL, Field
from gluon.validators import *

import eveapi
import datetime

api = eveapi.EVEAPIConnection()
db = DAL('sqlite://sqlite-latest.sqlite')
#----------------------------------------------------------------------------
db.define_table('invTypes')

I haven't figured out how to run a python file as part of an application, so I just make a test.py file inside the root web2py director and run it from command line ("py.exe test.py"). 


Does anyone know anything I could use to access this database?

Thanks,
Spencer Underwood

Niphlod

unread,
Apr 21, 2014, 12:15:18 PM4/21/14
to web...@googlegroups.com
to be able to access the data with DAL, you need to define tables that you want to use. If they exist already, as in your case, a simple migrate=False will turn the migrations off and just define the table without creating it.

db.define_table('....', migrate=False)
Reply all
Reply to author
Forward
0 new messages