[rust-dev] Generic Database Bindings

Laxmi Narayan NIT DGP nit.dgp673 at gmail.com
Sun Jun 22 01:35:23 PDT 2014


hey rust community , i want initiate this project ..
where can i get started ?





*          Laxmi Narayan Patel*

*               MCA NIT Durgapur (2011-2014)*

*          Mob:-    8345847473    *


On Tue, Jun 10, 2014 at 2:09 AM, Eli Green <eli at zigr.org> wrote:

> Having looked at this library and the other options out there, I have to
> say the designers of rust-postgres have built a very comfortable API and it
> would be an excellent place to start.
>
> The two pieces I see missing are:
>
> 1. A generic way to specify bindings inside queries. JDBC and ODBC use ?
> as a placeholder for parameters whereas Python's DB-API lets you use a
> number of different formats. This was a mistake (the API came after several
> modules that implemented a similar interface) and one of the things that
> SQLAchemy Core does for users is to define a single style for passing
> parameters.
>
> This part seems easy and by making a macro out of it, could even make
> rust-postgres' API slightly nicer:
>
> // current syntax
> conn.execute("SELECT a FROM b WHERE foo=$1 OR bar=$2", [&foo as &ToSql,
> &bar as &ToSql]);
>
> // possible syntax - handles the casting to ToSql for you
> conn.execute(sql!("SELECT a FROM b WHERE foo=$1 OR bar=$2", foo, bar));
>
> 2. rust-postgres defines two traits - ToSql and FromSql - which are what
> let the API do magical things as shown in their code snippet on their
> github page. I'm still learning about rust's type system but at the moment
> I don't see a way to make this work in a polymorphic environment.
>
> Not only that, some database drivers may support types that others do not.
> The geographic extension for PostgreSQL, PostGIS, can store geometries and
> send them to the user in a textual or binary format.
>
> This requirement could disappear if there was no need for the option to
> select a new driver at run-time, which is a feature common to all the other
> libraries I'm familiar with (though python technically doesn't do this -
> each module is completely stand-alone and there's no common code between
> them, the dynamic nature of python makes it trivial to load different
> modules based on runtime configuration).
>
> Does rust have any run-time type information built into the language? I've
> been assuming the answer is "no" given that one of the main design goals of
> the language is to avoid having a costly runtime.
>
> Eli
>
> On Jun 8, 2014, at 14:19, Steve Klabnik <steve at steveklabnik.com> wrote:
>
> > There isn't no. If you want to build a binding, just do it! The only
> > one I'm really aware of right now is
> > https://github.com/sfackler/rust-postgres
>
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140622/d9b05303/attachment.html>


More information about the Rust-dev mailing list