Giter Site home page Giter Site logo

Comments (4)

pacman82 avatar pacman82 commented on August 29, 2024 1

When you are sending all paramaters as strings, is the database still binding paramaters? If you are instead concatenating strings to generate an SQL statement that includes paramater values, these methods would be vulneratble to SQL injection.

These are bound VARCHAR parameters. arrow-odbc does not perform string concatination and does not introduce vulnerability to SQL injection.

Definitely don't convert a python float to an SQL decimal, since one is base 2 and the other is base 10.

SQL_DECIMAL is a relational type. It does not specify a representation. Multiple C-Types can be used to transfer SQL_DECIMAL.

I'm not sure why they picked SQL_NUMERIC instead of SQL_DECIMAL for python decimal.Decimal. Those two ODBC types look like aliases for the same type?

SQL_NUMERIC and SQL_DECIMAL differ in the range of values they support.

from arrow-odbc-py.

pacman82 avatar pacman82 commented on August 29, 2024 1

I'll give your suggestions some thought. With my current workload it is hypothetical anyway. The better error message must suffice for now. Thanks for alerting me to the issue.

from arrow-odbc-py.

pacman82 avatar pacman82 commented on August 29, 2024

Hello @rosscoleman ,

There's some overhead if the database has to cast types when binding paramaters, so I think it would be best to support Python ints, floats, and dates.

I am avoiding this as of now, as there is no clear mapping between Python and ODBC types. Should a float be converted to a double or a Decimal? Without inspecting the relational parameter type first, it is not possible to make a good decision in the genereal case. There is also not every conversion supported between ODBC types and Relational types on the database. String works everythere except for binary data.

I think you should add a more descriptive error message that only string query parameters are allowed

Good idea. Please enjoy arrow-odbc v1.2.4. Which shoud provide a better error messae.

from arrow-odbc-py.

rosscoleman avatar rosscoleman commented on August 29, 2024

When you are sending all paramaters as strings, is the database still binding paramaters? If you are instead concatenating strings to generate an SQL statement that includes paramater values, these methods would be vulneratble to SQL injection. If so, your API is really breaking my expectations about security. I've only ever used JDBC and pyodbc, and not ODBC from C or C++, but I wonder about this because JDBC drivers can throw errors if you send the wrong data types for bound parameters.


As for type conversions, I think pyodbc made sensible decisions. Definitely don't convert a python float to an SQL decimal, since one is base 2 and the other is base 10. I'm not sure why they picked SQL_NUMERIC instead of SQL_DECIMAL for python decimal.Decimal. Those two ODBC types look like aliases for the same type?

https://github.com/mkleehammer/pyodbc/wiki/Data-Types

https://learn.microsoft.com/en-us/sql/odbc/reference/appendixes/sql-data-types?view=sql-server-ver16

from arrow-odbc-py.

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.