Ed Leafe wrote:
> On Nov 23, 2008, at 9:13 PM, Paul McNett wrote:
>
>> We aren't talking about the server not existing, but the database
>> not existing.
>
> No, not exactly. You can connect to a server without specifying a
> database. With SQLite, the server *is* the database, so by connecting
> to a file that does not exist you are essentially creating the
> "server". If this were MySQL, you could specify a server, username and
> password and make a valid connection; no database is required to
> connect. To see what I mean, try the standard host=dabodev.com,
> user=webuser, pw=foxrocks with no database specified in the CxnEditor
> - it connects just fine.
You are proving my point.
With SQLite, the connection name becomes the database name. You get one
database per
connection. With other databases, you get a connection that can have several
databases.
So, for e.g. MySQL, if you connect without a database, there will be no active
database and you must cur.execute("use <database>") later, or preface the
database
name in all queries.
But for SQLite the database must exist, or creating the "connection" will
create it
for you.
Either way (sqlite or mysql) if CreateIfNotExists is True, we can create the
database
if it doesn't already exist, and (for mysql) use that database so it is the
current
database for further queries.
For sqlite, you must provide the path to the database file, or ":memory:". So
sqlite
is the exception to the general rule. But we should bail if the database
doesn't
exist, unless CreateIfNotExists is True, or the db is ":memory:".
And for all databases, we should provide a hook method (I guess this would be a
dApp
method) so that user code can create the tables for the newly-created database.
Or, if you hate that idea, and think that people should just create their
databases
and tables separately from Dabo, we should simply bail if the specified sqlite
database doesn't exist.
Paul
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]