Hey,
It took me a few tries before getting this to work. So, I see 2 things
that you may want to try to look at:
1) I don't really use windows, but I think the first line is
problematic. (unless more recent windows versions have gotten smarter
about slashes?).
>>> dbfolder='C:\web2py\web2py\applications\teqb\databases'
>>> db = dal.DAL('sqlite://storage', folder=dbfolder)
should be:
>>> dbfolder='C:/web2py/web2py/applications/teqb/databases'
(or you can escape the back slash (C:\\web2py\\web2py\\...))
2) I remember importing DAL was a little finicky (sometimes). SO, you
may want to try drilling down one more level in you import:
instead of
>>> db = dal.DAL('sqlite://storage', folder=dbfolder)
you may want to try:
from <yourPath>.gluon.dal import DAL
>>> db = DAL('sqlite://storage', folder=dbfolder)
I do the following without any problems on Mac, linux and windows: I
have 2 instances of web2py, some both running on the same machine, so
stand alone is renamed with "blue" prefixes (blueDAL, bluedb,
blueTHIS, blueTHAT, etc. and gluon is renamed to blueSQL in case they
run 2 different versions of web2py, I want to quickly and visually set
them apart when reading script.
tail,head = os.path.split(sys.argv[0])
dataFiles = ["storage.sqlite",
"sql.log"]
dbFolder = "{0}/blueLite/db_storage".format(tail)
try:
for f in os.listdir(dbFolder):
if ".table" in f:
fTable = "{0}/{1}".format(dbFolder,f)
os.remove(fTable)
print("removed {0}".format(fTable))
for dFile in dataFiles:
os.remove("{0}/blueLite/db_storage/{1}".format(tail,dFile))
print("removed {0}/blueLite/db_storage/
{1}".format(tail,dFile))
except Exception as errObj:
print(str(errObj))
from blueLite.pyUtils.sql.blueSQL.dal import DAL as blueDal
from blueLite.pyUtils.sql.blueSQL.dal import SQLField
bluedb = blueDal("sqlite://storage.sqlite", folder="{0}/blueLite/
db_storage".format(tail))
bluedb.define_table('cmdObjects',
SQLField('name'),
SQLField('pyModule'),
SQLField('pyPath'),
SQLField('cmdProperties','blob'),
SQLField('dict_objCmd','blob'),
SQLField('dfo_objCmd', 'blob'),
SQLField('etree_objCmd','blob'))
bluedb.commit()
Then I pass bluedb to all other classes which is why I use the full
path when pointing to the DB folder (NEVER relative).
hope it helps.
Mart :)
On Nov 18, 9:56 am, Ole Martin Maeland <[email protected]> wrote:
> Hi Massimo,
>
> I have administrator access on the folder. The database is running a small
> web2py application that is crypted. Do I have to pass the crypt string to
> the db, or do I have to use administrator password in order to access it.
>
> I reach it by using SQLite Manager..
>
> regards
> Martin
>
>
>
> On Thu, Nov 18, 2010 at 3:06 PM, mdipierro <[email protected]> wrote:
> > I think you do not have write access on this file/folder
>
> > On Nov 18, 7:36 am, Ole Martin Maeland <[email protected]> wrote:
> > > Hi,
>
> > > I am trying to connect to sqlite db that works fine with a small web2py
> > > applicaiton.
>
> > > connection parameters:
>
> > > >>> dbfolder='C:\web2py\web2py\applications\teqb\databases'
> > > >>> db = dal.DAL('sqlite://storage', folder=dbfolder)
>
> > > error message:
>
> > > Traceback (most recent call last):
> > > File "<interactive input>", line 1, in <module>
> > > File "C:\Python27\lib\site-packages\gluon\dal.py", line 2031, in
> > __init__
> > > self._logger = Logger(folder)
> > > File "C:\Python27\lib\site-packages\gluon\dal.py", line 140, in
> > __init__
> > > self.file = open(os.path.join(folder,name),'a')
> > > IOError: [Errno 22] invalid mode ('a') or filename:
> > > 'C:\\web2py\\web2py\x07pplications\teqb\\databases\\sql.log'
>
> > > any ide how I could get this to work?
>
> > > regards
> > > Martin
>
> --
> Hilsen
> Ole Martin
> Mob: 95227471