[vtk-developers] Re: vtkSQLDatabase
Shead, Timothy
tshead at sandia.gov
Wed Nov 28 14:46:21 EST 2007
> -----Original Message-----
> >> > Also why wouldn't SetURL/GetURL be public. Am I missing
> something?
> >> > Wouldn't you want to reconnect or connect to a different
> database?
> >> > Or do you guys enforce a new database object each time?
> >>
> >> vtkSQLDatabase is an abstract interface. There are concrete
> >> derivatives for specific database implementations, such as
> >> vtkSQLiteDatabase, vtkMySQLDatabase, etc. The problem is that
> >> SetURL() encourages the user to do things that can't work:
> >>
> >> // Returns an instance of vtkSQLiteDatabase
> >> vtkSQLDatabase* db =
> >> vtkSQLDatabase::CreateFromURL("sqlite:///home/tshead/mydb");
> >> // Now what?
> >> db->SetURL("mysql://tshead@localhost:3306/myotherdb");
> >
> > Alright, that makes sense now. I didn't pay close attention
> to the URL
> > syntax, I didn't notice it had the db type in it.
> > I'm not a huge fan of that CreateFromURL method, it looks
> kinda non-
> > VTK-ish to me, but that's probably because I'm old-fashion VTK :)
> Hmm, I got the idea from vtkDataArray::CreateDataArray( int
> dataType ). :-)
Perhaps a factory function for creating database instances based on URL
doesn't go far enough ... maybe what you want is a
"vtkUniversalSQLDatabase" object that can provide SetURL() / GetURL()
functionality and use the underlying concrete databases as part of its
implementation.
Cheers,
Tim
More information about the vtk-developers
mailing list