FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Welcome to DDBI!

 
Post new topic   Reply to topic     Forum Index -> DDBI
View previous topic :: View next topic  
Author Message
jeremy_c



Joined: 09 Apr 2005
Posts: 16
Location: Ohio, USA

PostPosted: Tue Apr 26, 2005 8:24 am    Post subject: Welcome to DDBI! Reply with quote

First, I want to thank DSource.org for hosting these services.

Second, I want to introduce D DBI. D DBI is a database independent interface for the D programming language. What this means is a common interface to many types of database backends.

For instance:

Code:
import dbi.sqlite.SqliteDatabase;
//import dbi.pg.PgDatabase;
//import dbi.mysql.MysqlDatabase;

void main() {
  // PgDatabase db = new PgDatabase();
  // MysqlDatabase db = new MysqlDatabase();
  // db.connect("dbname=test");

  SqliteDatabase db = new SqliteDatabase();
  db.connect("_test.db");

  Row[] rows = db.queryFetchAll("SELECT * FROM names");
  for (Row row; rows) {
    printf("name: ?.*s zip: ?.*s\n", row["name"], row["zip"]);
  }

  db.close();
}


That program will work on all database systems that D DBI currently supports without change, except the connect statement. As you can see, at the time of this post, D DBI supports SQLite v3, MySQL and PostgreSQL.

It is my hopes that the community will begin discussion of D DBI and through a community effort shape D DBI into a full featured DBI system for the D programming language. Others have already contributed to the code, such as the SQLite3 C wrapper and the MySQL C wrapper.

D DBI's home page is currently http://jeremy.cowgar.com/ddbi/ but will soon be changing to ddbi.dsource.org (thanks again to dsource.org). Downloads are currently available there.

Feel free to start the discussion! The API needs some work, more database drivers need to be added, better documentation and example programs needs to be created however, in it's current state, it is very usable. So, let the discussion and use begin!

Jeremy Cowgar
http://jeremy.cowgar.com
[/code]


Last edited by jeremy_c on Tue Apr 26, 2005 1:08 pm; edited 1 time in total
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Tue Apr 26, 2005 9:38 am    Post subject: Reply with quote

Welcome to dsource!

I've been over your API multiple times, and I think I found some things that would be very nice to have.

1) escape sequences. Different database vendors have slightly different conventions on how to deal with embeded single-quotes and the like. I see a reference to an 'escape' function in your doc index, but shouldn't this be tied to the various db implementation classes instead?

Code:

db.queryFetchAll("select * from mytable where x = '" ~ db.escape(mystr) ~ "'");


Also, a writef-like version of this that automatically escapes would be even better:

Code:

db.queryFetchAll("select * from mytable where x='{0}' and y='{1}'",mystr,mystr2);



2) It would be nice to have a 'query' object that can be resued in places, instead of having to wield SQL all the time.

Code:

Query q = db.createQuery("select * from mytable where x='{0}' and y='{1}'");
Reqsult r = q.fetchAll(mystr,mystr2);


(createQuery could self-optimize by breaking down the string into text and subtitution parts... so parsing overhead can be eliminated later on)

IMO, This would help in further side-stepping the differences between database vendors as no two SQL implementations are alike. Smile
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
jeremy_c



Joined: 09 Apr 2005
Posts: 16
Location: Ohio, USA

PostPosted: Tue Apr 26, 2005 10:22 am    Post subject: Reply with quote

pragma wrote:
Welcome to dsource!


Thanks!

pragma wrote:

I've been over your API multiple times, and I think I found some things that would be very nice to have.


I've started seperate threads for these, please see:

http://www.dsource.org/forums/viewtopic.php?t=762
http://www.dsource.org/forums/viewtopic.php?t=763

Jeremy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DDBI All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group