[Gambas-user] Rename a file in filesystem

Benoit Minisini gambas at ...1...
Fri Jan 25 00:40:44 CET 2008


On jeudi 24 janvier 2008, Paolo Fagni wrote:
> On Jan 24, 2008 5:13 PM, Ron Onstenk <ronstk at ...239...> wrote:
> > On Thursday 24 January 2008 15:44, Paolo Fagni wrote:
> > > This is kind of an annoying problem. I post here the sub that I would
> >
> > like
> >
> > > to use to create a new sqlite file:  It doesn't work if, in the dialog,
> >
> > I
> >
> > > chosse a neme with a point in it ("xxx.db for example")
> > >
> > > ' Creates a new, empty, database.
> > > PUBLIC SUB CreateNew() AS Boolean
> > >
> > >   TRY dbConnection.Close()
> > >
> > >   Dialog.Path = Application.Path
> > >   Dialog.Title = ("Please choose a filename")
> > >   IF Dialog.SaveFile() THEN RETURN
> > >   DbPath = Dialog.Path
> > >
> > >   IF Exist(DbPath) THEN ' Check if the file exists
> > >     Message.Error(("File already exists!"))
> > >     RETURN FALSE
> > >   ENDIF
> > >
> > >   dbConnection.Name = DbPath
> > >   dbConnection.Type = "sqlite3"
> > >   dbConnection.Open()
> > >
> > >   dbConnection.Close()
> > > END
> > >
> > >
> > > Gambas fails with "Unable to locate database : /path/to/xxx.db
> >
> > Your database name is here 'xxx' and sqlite stores the data into the file
> > 'xxx.db'
> > Not strange sqlite does not accept a name of 'xxx.db' here and tells
> > gambas it
> > cant handle. I'm afraid gambas is not in error but sqlite or even better
> > the user
> > is using wrong filename.
>
> I forgot to mention that in the Dialog I chose xxx.db for the filename, not
> xxx, because I want my file to be called xxx.db and not xxx or xxx.db. I
> can rename the file after the creation and everythiong work fine. I'm
> simply unable to create it directly from gambas
>
> > It is not imposible sqlite does not accept a dot in the database name for
> > 3 reasons.
> > 1) it is used between the tablename and fieldname (i.e.
> > tablename.fieldname)
> > 2) it is used between the database and table name (i.e.
> > databasename.tablename)
> > 3) it is used as extention for the file name in the filesystem.
> >
> > > Gambas version 2.0.0 on an arch linux box.
> > >
> > > Any help would be appreciated, Thank you! :D
> >
> > Just try if you can create a database with the name xyx.abc
> > and use the commandline util for sqlite to do this (if exists)
> > If both, the .abc and .db, works than it may a problem with gambas.
> > But remember the database part of gambas must be able to work on many
> > database
> > systems and not all allow a dot in the database, table and/or field name.
> >
> > Greets,
> >
> > Ron Onstenk
>
> Sqlite works very well with database files named with a point.
>
> Thank you Ron for your answer :) If someone else has something to clarify
> this strange behaviour , it'd be great , thanks.

It's just that '.' is a character forbidden by the database component. I admit 
that this is a bit stupid in the sqlite case. I will see what I can do for 
the 2.1.

Regards,

-- 
Benoit Minisini




More information about the User mailing list