Git Product home page Git Product logo

Comments (9)

AndriiSherman avatar AndriiSherman commented on July 17, 2024 5

@ysm-dev we have released support for proxy requests in 0.17.4.
Here is small code snippet for SQLite Proxy Driver

const db = drizzle(async (sql, params, method) => {
  try {
    const rows = await axios.post('http://localhost:3000/query', {
      sql,
      params,
      method,
    });

    return { rows: rows.data };
  } catch (e: any) {
    console.error('Error from sqlite proxy server: ', e.response.data);
    return { rows: [] };
  }
});

You can read release notes and also here is a link for full usage example

Using this example you can make any driver on server side to execute raw queries

Fell free to ping me, if something won't work for you

from drizzle-orm.

AlexBlokh avatar AlexBlokh commented on July 17, 2024 1

@ysm-dev hey!
can you please share a raw example of what you're trying to achieve?
we have examples with FlyIO LiteFS, yet they have a fs layer
I'm not sure how that works in Vercel

ps: we've discussed mocked db to use as query builder, we'll implement soon

from drizzle-orm.

AlexBlokh avatar AlexBlokh commented on July 17, 2024 1

@ysm-dev we'll provide you an interface for that one of these days

from drizzle-orm.

ysm-dev avatar ysm-dev commented on July 17, 2024

@AlexBlokh thank you for quick reply!
I'm trying to build SQL Query inside Vercel Edge Runtime and
send that SQL Statement to Cloudflare Workers (D1) over http.

1 more question:

I'm using SQLite + Cloudflare D1,
and when I insert with undefined or null values, it saved as string it self:
image
image

is it bug? or feature?

Thank you for great library!

from drizzle-orm.

AlexBlokh avatar AlexBlokh commented on July 17, 2024

@ysm-dev so you're sending http request to Cloudflare worker, propagate it to D1 and send D1 response back?

if you can provide us an example project or a code snippet for that - would be very helpful

from drizzle-orm.

AlexBlokh avatar AlexBlokh commented on July 17, 2024

@ysm-dev btw if you're using Cloudflare, why would you need Vercel?

from drizzle-orm.

ysm-dev avatar ysm-dev commented on July 17, 2024

@ysm-dev so you're sending http request to Cloudflare worker, propagate it to D1 and send D1 response back?

if you can provide us an example project or a code snippet for that - would be very helpful

Yea I want to build SQL statements (with drizzle) outside of Cloudflare workers and send the Query object over HTTP,

// ex) Query object
{
  sql: 'select * from user',
  params: []
}

and run this Query in Cloudflare Workers with DrizzleORM + D1, and return it.

So Cloudflare Workers is like just SQL Runner.

And wants to use all type-safety outside of Worker.

How can I achieve this?

from drizzle-orm.

ysm-dev avatar ysm-dev commented on July 17, 2024

@AlexBlokh Thank you!

from drizzle-orm.

ysm-dev avatar ysm-dev commented on July 17, 2024

@AndriiSherman Thank you for the quick feedback and update!
I tried a Proxy driver with CF D1 Database, but there is no prepare type in D1 drizzle instance.
image

from drizzle-orm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.