From rob.kinyon at gmail.com Fri Mar 13 17:00:55 2020 From: rob.kinyon at gmail.com (Rob Kinyon) Date: Fri, 13 Mar 2020 17:00:55 -0400 Subject: [DB-SIG] Connecting to a REST API Message-ID: For various reasons (not all of them sane), one of my clients wants to implement a data access layer using a REST API that provides a single route which takes a SQL statement as its only parameter and returns the result of that statement as an array of hashes in JSON. (For now, please ignore the problems of performance and all the other issues that arise around replacing a stateful binary protocol with a stateless textual one.) For the purposes of this question, let's assume that all queries are SELECT statements, each query is its own transaction, and the entire result is returned in one response (all responses are small-ish and cursors are implemented completely on the client-side). Ideally, my client would like to provide SQLAlchemy as an interface for its developers and enable SQLAlchemy to use a module that would take the place of pymysql or psycopg2. Vs, say, everyone reimplementing that work using requests. So, my question: Is there an existing Python database module that either does this or does something very close to it that I can crib from? -- Thanks, Rob Kinyon -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike_mp at zzzcomputing.com Sun Mar 15 11:24:33 2020 From: mike_mp at zzzcomputing.com (Mike Bayer) Date: Sun, 15 Mar 2020 11:24:33 -0400 Subject: [DB-SIG] Connecting to a REST API In-Reply-To: References: Message-ID: <6d988905-3586-4b9f-afd2-38272b4e84b7@www.fastmail.com> There are a few products that do this, there is one that I'm familiar with which is built off of SQLAlchemy called slashdb https://www.slashdb.com/ . it is commercial, but appears to offer a free development version. On Fri, Mar 13, 2020, at 5:00 PM, Rob Kinyon wrote: > For various reasons (not all of them sane), one of my clients wants to implement a data access layer using a REST API that provides a single route which takes a SQL statement as its only parameter and returns the result of that statement as an array of hashes in JSON. (For now, please ignore the problems of performance and all the other issues that arise around replacing a stateful binary protocol with a stateless textual one.) For the purposes of this question, let's assume that all queries are SELECT statements, each query is its own transaction, and the entire result is returned in one response (all responses are small-ish and cursors are implemented completely on the client-side). > > Ideally, my client would like to provide SQLAlchemy as an interface for its developers and enable SQLAlchemy to use a module that would take the place of pymysql or psycopg2. Vs, say, everyone reimplementing that work using requests. So, my question: > > Is there an existing Python database module that either does this or does something very close to it that I can crib from? > > -- > Thanks, > Rob Kinyon > _______________________________________________ > DB-SIG maillist - DB-SIG at python.org > https://mail.python.org/mailman/listinfo/db-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cito at online.de Sun Mar 15 12:11:48 2020 From: cito at online.de (Christoph Zwerschke) Date: Sun, 15 Mar 2020 17:11:48 +0100 Subject: [DB-SIG] Connecting to a REST API In-Reply-To: <6d988905-3586-4b9f-afd2-38272b4e84b7@www.fastmail.com> References: <6d988905-3586-4b9f-afd2-38272b4e84b7@www.fastmail.com> Message-ID: <5408e57e-523c-8232-4034-5127220abce4@online.de> Am 15.03.2020 um 16:24 schrieb Mike Bayer: > There are a few products that do this, there is one that I'm familiar > with which is built off of SQLAlchemy called slashdb > https://www.slashdb.com/ . it is commercial, but appears to offer a > free development version. If you use PostgreSQL, http://postgrest.org is a free option. However, you can't execute arbitrary SQL so easily, see http://postgrest.org/en/v6.0/api.html#custom-queries In SlashDB you also need to define the SQL queries first, so maybe that's also not flexible enough. https://www.slashdb.com/how-it-works/#sql-pass-thru Actually it looks like you want GraphQL, not REST. Again, if you use PostgreSQL, have a look at https://www.graphile.org/postgraphile/ -- Christoph