You are not logged in.
Pages: 1
Maybe I am not looking straight ... but I can't seem to find any possibility to create a new database through a TSQLDBconnection or TSQLDBConnectionproperties...
Any plans on this?
Offline
SQLite3 databases (i.e. SQLite3 files) are created by the framework.
But up to now, we must have an existing database, for all external DB engines.
From my little experiment, creating a database is not a trivial task.
You have to use tools or connect in a special mode, not handled by OleDB or ODBC for instance.
Under Oracle for instance, you should better use the Wizard, otherwise you'll have a lot of commands to run.
So there is no plan on this.
There is already a TOleDBConnectionProperties.CreateDatabase virtual method, used e.g. to create a Jet/MSAccess file.
We may define this method at TSQLDBConnectionProperties generic level, then call it from ORM, e.g. for Jet or Nexus.
But should be difficult to make it generic.
I suspect the easiest could be to implement the same behavior as SQLite3, for the DB engines which may be able to easily create databases: if the database does not exist, try to create it.
That is, an auto-creation feature, not a specific ORM command.
Offline
OK, i'll add my own implementation of CreateDatabase to my NexusDB driver.
Maybe its an idea to add some kind of "CanCreate():boolean" function to the main TSQLDBCOnnectionProperties, or add interfaces to let the code determine if its possible to create a database, independent of the actual TConnectionproperties implementation..
type
ICanCreateDatabase = interface(IInterface)
['{C6A016A5-2A6E-48F6-9A4D-310B643B53C0}']
function CanCreate: boolean;
function DatabaseExists: boolean;
function CreateDatabase: boolean;
end;
Offline
Good idea.
I've added this feature to the mORMot roadmap.
Offline
Pages: 1