Comments (10)
@cemmerven I'm pretty sure you didn't mean to tag me, right?
from pydapper.
thanks for the feedback - I think I will implement a CommandType
enum and corresponding command_type
kwarg on relevant methods
from pydapper.
I still plan to work on this, I've just had a busy month. Plan to pick this up in the next week or so.
from pydapper.
Thanks for the issue! I’ll dig into this a bit and try to add some stored proc calls to the docs/test suite
from pydapper.
this is taking a bit longer as calling sprocs doesn't "just work". Per the db api for procs, I need to think about how I can provide an interface for callproc. Which feels more natural?
Note that in pydapper, you pass params as ?paramname?
as opposed to the @Param
used by dapper.
Option 1
with pydapper.connect() as commands:
commands.query_proc("MyProc ?param1? ?param2?", params={"param1": "Hello", "param2": "world"})
Option 2
with pydapper.connect() as commands:
commands.query("MyProc ?param1? ?param2?", params={"param1": "Hello", "param2": "world"}, proc=True)
from pydapper.
it would be great to get some others input on this as well, esp if you have had experience using dapper directly. Tagging a few below..
@troyswanson
@deasko
@JonTheTurnip
@otosky
@bruce-dunwiddie
from pydapper.
this is taking a bit longer as calling sprocs doesn't "just work". Per the db api for procs, I need to think about how I can provide an interface for callproc. Which feels more natural?
Note that in pydapper, you pass params as
?paramname?
as opposed to the@Param
used by dapper.Option 1
with pydapper.connect() as commands: commands.query_proc("MyProc ?param1? ?param2?", params={"param1": "Hello", "param2": "world"})Option 2
with pydapper.connect() as commands: commands.query("MyProc ?param1? ?param2?", params={"param1": "Hello", "param2": "world"}, proc=True)
Option 2 is how I've seen it done in many languages, including core .Net classes, where it's just called through the same method, but specifying a "command type":
pyodbc apparently just depends on the "EXEC" syntax, https://code.google.com/archive/p/pyodbc/wikis/StoredProcedures.wiki , which seems to match up to @cemmerven 's second syntax attempt above:
commands.query_first( "execute sp_TestCall", param= { "foo": 1, "bar": U"some text" } )
from pydapper.
Hi all, I haven't thought about this too much but I think I'm also more in favor of option 2, I can't see any obvious problems with that approach.
from pydapper.
in the mean time @cemmerven, this should work for you with the current release
commands.query_first("exec sp_TestCall ?foo? ?bar?", param=dict(foo=1, bar="some text"))
from pydapper.
after trying multiple different solutions, I ultimately couldn't find something that work well in python without being kind of awkward for at least one of the DBMS' that pydapper supports. The reality is that callproc
is inconsistently implemented across the various dbapis, and because of that its hard to come up with a consistent interface that works for everything.
For now, I'm not planning on putting this into a future release, but I will plan to continue to think on it.
The below will work on all pydapper methods, however and is the solution I recommend in the interim. As @bruce-dunwiddie mentioned, this is the path that pyodbc took for the same reason.
with pydapper.connect(MSSQL_URL) as commands:
result = commands.query("EXEC GetTaskById @Id = ?id?", param={"id": 1})
from pydapper.
Related Issues (20)
- Shortening Code HOT 1
- 🔧 Better error messages when params in your query don't match param input
- Returning data from "RETURNING" clause of INSERT HOT 12
- How to document a CASCADE HOT 2
- SSL support HOT 1
- 🔧 Speed up CI
- ✨ add async support
- WARNING: pydapper 0.1.1a2 does not provide the extra 'mysql-connector-python' HOT 2
- Custom column mapping HOT 6
- Add support for new oracledb package HOT 5
- Add Sybase connection HOT 2
- Fix black dependency
- Support Python 3.12 HOT 2
- Deprecate cxOracle in favor of `oracledb` HOT 1
- how to connect to sql server using windows authentication HOT 4
- How can I serialize a one to many relationship? HOT 2
- Reimplement the query method HOT 1
- Add documentation that pymssql requires an explicit commit HOT 4
- add a `buffered` kwarg to query
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pydapper.