Hey Tor, 2014-03-31 9:57 GMT+02:00 Tor Arne Fallingen <[email protected]>:
> Hey, > > Its monday morning and most I have most of my db-handler up and running, > but there is one thing I wonder about, which I haven't seen any obvious > example of yet. Would it be possible to create a new database using the Dbo > backend? I create several tables, but if I put our application into a clean > installed Raspberry Pi, it would be sweet if it also created the database > for which our tables are stored in. I tried searching for a > <<createDatabase>> command, and looked briefly through the hands on guide. > But Ive been using all references quite extensively lately, and I can't > remember seeing a createDatabase like method. > Great question. Although I haven't researched this, I am sure this is database specific. For example, the sqlite3 backend will actually create a database if it doesn't exist, since it's as simple as creating a file. The other databases require you to connect to a database and then run a SQL 'create database' command. So you already need to have a database (and postgres always has the 'template1' system database) for the user to connect to, and the user needs to have the right privileges to be able to create new databases. In this case you can do this using Wt::Dbo by creating a (temporary) Session and using Session::execute(). Regards, koen
------------------------------------------------------------------------------
_______________________________________________ witty-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/witty-interest
