[Gambas-user] Rename a file in filesystem

Paolo Fagni paolo.fagni at ...626...
Thu Jan 24 18:52:11 CET 2008


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.

-- 
Paolo Fagni



More information about the User mailing list