News for hackers. Stuff that matters.
Re:PRQL – A proposal for a better SQL by nassimsoftware on Monday January 24, 2022 @01:03PM (#30061365)
It would be definitely interesting to have a TypeScript of some sort but for SQL. So a more practical and prettier syntaxe like what I'm seeing here that compiles to SQL queries.
Re:PRQL – A proposal for a better SQL by dirslashls on Monday January 24, 2022 @01:38PM (#30061913)
Go to https://sqlframes.com/demo and in the code editor enter the following and execute (this example is taken from the first example on PRQL github page). It generates SQL, but it also computes and displays the results within the browser (though the data set below gives no results).

const employees = SQL.values([{ title: 'Developer', country: 'USA', salary: 120, payroll_tax: 20, healthcare_cost: 6 }]); employees.schemaName = 'employees'; const { groupBy, where: { gt, eq, and }, agg: { count, sum, avg } } = SQL; return employees.pdf(SQL.script('[salary]+[payroll_tax]').as('gross_salary'),SQL.script('[gross_salary]+[healthcare_cost]').as('gross_cost')) .fdf(and(gt('gross_cost',0),eq('country','USA'))) .gdf(groupBy('title','country') ,avg('salary').as('average_salary') ,sum('salary').as('sum_salary') ,avg('gross_salary').as('average_gross_salary') ,sum('gross_salary').as('sum_gross_salary') ,avg('gross_cost').as('average_gross_cost') ,sum('gross_cost').as('sum_gross_cost') ,count().as('count')) .having(gt('count',200)) .orderBy('sum_gross_cost');

Re:PRQL – A proposal for a better SQL by eatonphil on Monday January 24, 2022 @01:04PM (#30061387)
TypeScript is more verbose than JavaScript. While I love to use TypeScript I don't think I'd categorize it as prettier than JavaScript. And practical... well if you mean it is more maintainable then yes but if you mean faster to write then no.

I don't want a more verbose SQL I want a less verbose SQL!

Re:PRQL – A proposal for a better SQL by nassimsoftware on Monday January 24, 2022 @01:11PM (#30061488)
I meant more the aspect that with TypeScript people would prefer to write in it and then compile to JavaScript because there is a benefit. With a PRQL with an SQL compilation target we would reap the benefit of a more practical and better syntax. In both cases they bring benefits but not in the same way.
Re:PRQL – A proposal for a better SQL by text2db on Tuesday January 25, 2022 @04:59AM (#30070136)
>I don't want a more verbose SQL I want a less verbose SQL!

A little off topic, but I have created many databases by writing and converting simple text to database scripts

Try this: https://text2db.com/