-
-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSSQL Query Support #57
Comments
Thanks for reporting! It would make sense to support many different database systems, but I would ideally like to add a uniform interface. But for different databases, I guess it makes sense to add different interfaces. I'll have to think a bit more about what the best design for this would be. |
I guess? I'm just imagining running some SQL and getting back a table of results, or the appropriate response depending on the type of query. I don't think it needs to be different at the Lua level, it's more that I imagine a separate Go implementation is needed for each DB because the driver will vary. Anyway, you are probably thinking with all that. Any thought of when you might take a crack at this--next week, a few months? |
Adding support should be quick, a week or two, but I might need to set up a MSSQL server just for testing. Do you happen to know if this module is known to work well? |
Nice :)
Yes, that's what I've used in the past and it worked fine. |
I added a new |
Wow, great! Will let you know. |
Still trying it out, but can confirm I can |
Would be good to scan rows into 2-dimensional tables. Perhaps this would work: // StringSlices2table converts a slice of string slices to a Lua table
func StringSlices2table(L *lua.LState, sl [][]string) *lua.LTable {
table := L.NewTable()
for _, inner := range sl {
sub := L.NewTable()
for _, element := range inner {
sub.Append(lua.LString(element)
}
table.Append(sub)
}
return table
} And then in |
Two additional points:
local result = MSSQL([[ SELECT r, g, b, a FROM [My Colors] WHERE name = @p1 ]], connstr, "mauve")
<ul>
{% for index, item in doquery() sorted %}
<li>{{ index }}</li>
{% endfor %}
</ul> I get this output:
|
Those are pretty good suggestions, thanks! I like the idea of keeping the I'll either update the function or add another one. |
Great, thanks! I'm excited for this. (For whatever you end up doing, I want to retract my earlier offhand code suggestion of |
@xyproto so in my fork I have I am not sure if the best way to proceed is by producing a |
This is now mostly complete with #61 Lastly I will need to check the pongo2 sorting and do a PR to fix that if necessary. |
Thank you for the pull request and fix! |
I quite like the server you've put together, it checks a few boxes I'm interested in for a particular project.
I see you have
PQ()
for doing arbitrary Postgres queries. I need to support MSSQL; perhaps we could add aMSQ()
function? Seems straightforward, basically copyinglua/pquery/pquery.go
and importing the appropriate driver.Let me know what you think.
The text was updated successfully, but these errors were encountered: