Odbc escape convert error

Hy000 Odbc Escape Convert Error We have collected for you the most relevant information on Hy000 Odbc Escape Convert Error, as well as possible solutions to this problem. Take a look at the links provided and find the solution that works. Other people have encountered Hy000 Odbc Escape Convert Error before you, so use […]

Содержание

  1. Hy000 Odbc Escape Convert Error
  2. Solved: ODBC: ERROR [HY000] [MySQL][ODBC 1.2(w) Driver][my .
  3. PostgreSQL: Re: ODBC escape convert error
  4. SSIS ODBC connection Error HY000 — social.msdn.microsoft.com
  5. Solved: Microsoft.Data.Odbc.OdbcException: ERROR [HY000 .
  6. Hive ODBC Exception — ERROR [HY000] [Hortonworks .
  7. Solved: ERROR [HY000] [Microsoft][ODBC Microsoft Access .
  8. PostgreSQL: Re: ODBC escape convert error
  9. Solved: Datasource error — unable to convert — Microsoft .
  10. Escaping the ODBC Escape Sequence
  11. Hy000 Odbc Escape Convert Error Fixes & Solutions
  12. Odbc escape convert error
  13. Answered by:
  14. Question
  15. Re: ODBC escape convert error
  16. In response to
  17. Responses
  18. Browse pgsql-odbc by date
  19. Odbc escape convert error
  20. Answered by:
  21. Question
  22. Odbc escape convert error
  23. Лучший отвечающий
  24. Вопрос

Hy000 Odbc Escape Convert Error

We have collected for you the most relevant information on Hy000 Odbc Escape Convert Error, as well as possible solutions to this problem. Take a look at the links provided and find the solution that works. Other people have encountered Hy000 Odbc Escape Convert Error before you, so use the ready-made solutions.

Solved: ODBC: ERROR [HY000] [MySQL][ODBC 1.2(w) Driver][my .

    https://community.powerbi.com/t5/Desktop/ODBC-ERROR-HY000-MySQL-ODBC-1-2-w-Driver-mysqld-5-7-12-mongosqld/td-p/568285
    Nov 19, 2018 · ODBC: ERROR [HY000] [MySQL][ODBC 1.2(w) Driver][mysqld-5.7.12 mongosqld v2.8.1]Unknown database ‎11-18-2018 11:14 PM Hi Geeks,

PostgreSQL: Re: ODBC escape convert error

    https://www.postgresql.org/message-id/[email protected]
    From Date Subject; Next Message: Richard Broersma: 2008-06-11 19:07:31: Re: [ODBC] what gives: SELECT INVALID SELECT STATEMENT TO FORCE ODBC DRIVER TO UNPREPARED STATEAuthor: Hiroshi Inoue
    https://social.msdn.microsoft.com/Forums/en-US/44119327-9cd2-49a4-b059-5a6533ae9688/ssis-odbc-connection-error-hy000
    Jul 23, 2018 · MSDN Community Support Please remember to click «Mark as Answer» the responses that resolved your issue, and to click «Unmark as Answer» if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected]

Solved: Microsoft.Data.Odbc.OdbcException: ERROR [HY000 .

    https://www.experts-exchange.com/questions/20864527/Microsoft-Data-Odbc-OdbcException-ERROR-HY000-Microsoft-ODBC-Microsoft-Access-Driver-Operation-must-use-an-updateable-query.html
    Microsoft.Data.Odbc.OdbcEx ception: ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query. * I am using this to execute the SQL statement: Try Dim conn As New OdbcConnection(ConnectionS tring) conn.Open() Dim objCommand As New OdbcCommand() .

Hive ODBC Exception — ERROR [HY000] [Hortonworks .

    https://community.cloudera.com/t5/Support-Questions/Hive-ODBC-Exception-ERROR-HY000-Hortonworks-Hardy-35-Invalid/td-p/224694
    Jun 23, 2017 · Hi folks, I was working on using C# to pull binary content from Hive over ODBC, but ran into an exception when the BLOB size is over 30MB. The query was straightforward and retrieves one record with BLOB content. Any thoughts? Thank you. DbDataReader dr = …

Solved: ERROR [HY000] [Microsoft][ODBC Microsoft Access .

    https://www.experts-exchange.com/questions/21794384/ERROR-HY000-Microsoft-ODBC-Microsoft-Access-Driver-Disk-or-network-error-ERROR-IM006-Microsoft-ODBC-Driver-Manager-Driver’s-SQLSetConnectAttr-failed-ERROR-HY000-Microsoft-ODBC-Microsoft.html
    Dec 03, 2013 · ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver’s SQLSetConnectAttr failed ERROR [HY000] [Microsoft][ODBC Microsoft pavanipolu asked on 2006-03-29

PostgreSQL: Re: ODBC escape convert error

    https://www.postgresql.org/message-id/[email protected]
    On Wed, Jun 11, 2008 at 11:49 AM, Hiroshi Inoue wrote: > You may have to replace ‘ <‘ (ODBC escape) by ‘(‘ in the line.

Solved: Datasource error — unable to convert — Microsoft .

    https://community.powerbi.com/t5/Power-Query/Datasource-error-unable-to-convert/td-p/368603
    DataSource.Error: ODBC: ERROR [HY000] [MySQL][ODBC 5.3(w) Driver][mysqld-5.7.12 mongosqld v2.3.1]column ‘Table1.Column1’: unable to convert ‘0.00’ (string) to float64 This is just one of the Errors I get when connecting to my Mongo Atlas DB, others have similar nature. The ODBC connection is worki.

Escaping the ODBC Escape Sequence

    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/bc64f99b-c7c0-4d07-b8af-77a269b3c109/escaping-the-odbc-escape-sequence
    Oct 27, 2014 · failed with the following error: «ODBC escape convert error». Possible failure reasons: Problems with the query, «ResultSet» property not set correctly, parameters not set correctly, or connection not established correctly. Thursday, October 16, 2014 6:53 PM. Answers

Hy000 Odbc Escape Convert Error Fixes & Solutions

We are confident that the above descriptions of Hy000 Odbc Escape Convert Error and how to fix it will be useful to you. If you have another solution to Hy000 Odbc Escape Convert Error or some notes on the existing ways to solve it, then please drop us an email.

Источник

Odbc escape convert error

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

For the love of god and all that is holy, how on earth do you ESCAPE the ODBC Escape characters <> (curly braces) within an Execute SQL Task in a DTS package .

I’m using PostgreSQL ANSI ODBC driver 9.03.02.10 connecting to redshift to perform an unload. The caveat is that my query has a regex in it wrapped in an unload. I’ve created the example below to display what is happening.

Unloads in redshift have to be wrapped in single quote ( ‘ ), of course escaping any quotes that need to go along for the ride. When it gets to the < it thinks I want to do an ODBC escape to do something like this http://msdn.microsoft.com/en-us/library/ms711838(v=vs.85).aspx but I don’t want it to. I’ve tried setting < escape ‘#’ >, I’ve tried all the combos of escapes I can. Is there a way to escape this, or disable ODBC Escape Sequences in the package or anything of that nature?

This query works as it should(within the Exec SQL task) when it is not wrapped in the single quotes. For example, running the script without it being wrapped in the UNLOAD(‘ ‘) command executes successfully.

PARALLEL OFF;[Execute SQL Task] Error: Executing the query «UNLOAD(‘ SELECT * FROM testing_regex WHERE 1=1 AND. » failed with the following error: «ODBC escape convert error». Possible failure reasons: Problems with the query, «ResultSet» property not set correctly, parameters not set correctly, or connection not established correctly.

Источник

Re: ODBC escape convert error

From: Hiroshi Inoue
To: Richard Broersma
Cc: pgsql-odbc(at)postgresql(dot)org
Subject: Re: ODBC escape convert error
Date: 2008-06-11 18:49:21
Message-ID: 48501E31.5030107@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Richard Broersma wrote:
> I’ve attached a log file with the code for a prepared insert command.
> However, when it is executed, I am getting the error:
>
> ODBC escape convert error.
>
> It looks like the query never makes it to the sever becuase I don’t
> see any statement logged for it. Does anyone have any ideas?

In response to

  • ODBC escape convert error at 2008-06-11 17:48:23 from Richard Broersma

Responses

  • Re: ODBC escape convert error at 2008-06-11 19:36:17 from Richard Broersma

Browse pgsql-odbc by date

From Date Subject
Next Message Richard Broersma 2008-06-11 19:07:31 Re: [ODBC] what gives: SELECT INVALID SELECT STATEMENT TO FORCE ODBC DRIVER TO UNPREPARED STATE
Previous Message Fred Parkinson 2008-06-11 18:37:49 Access query as executed by postgres

Copyright © 1996-2023 The PostgreSQL Global Development Group

Источник

Odbc escape convert error

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

For the love of god and all that is holy, how on earth do you ESCAPE the ODBC Escape characters <> (curly braces) within an Execute SQL Task in a DTS package .

I’m using PostgreSQL ANSI ODBC driver 9.03.02.10 connecting to redshift to perform an unload. The caveat is that my query has a regex in it wrapped in an unload. I’ve created the example below to display what is happening.

Unloads in redshift have to be wrapped in single quote ( ‘ ), of course escaping any quotes that need to go along for the ride. When it gets to the < it thinks I want to do an ODBC escape to do something like this http://msdn.microsoft.com/en-us/library/ms711838(v=vs.85).aspx but I don’t want it to. I’ve tried setting < escape ‘#’ >, I’ve tried all the combos of escapes I can. Is there a way to escape this, or disable ODBC Escape Sequences in the package or anything of that nature?

This query works as it should(within the Exec SQL task) when it is not wrapped in the single quotes. For example, running the script without it being wrapped in the UNLOAD(‘ ‘) command executes successfully.

PARALLEL OFF;[Execute SQL Task] Error: Executing the query «UNLOAD(‘ SELECT * FROM testing_regex WHERE 1=1 AND. » failed with the following error: «ODBC escape convert error». Possible failure reasons: Problems with the query, «ResultSet» property not set correctly, parameters not set correctly, or connection not established correctly.

Источник

Odbc escape convert error

Лучший отвечающий

Вопрос

For the love of god and all that is holy, how on earth do you ESCAPE the ODBC Escape characters <> (curly braces) within an Execute SQL Task in a DTS package .

I’m using PostgreSQL ANSI ODBC driver 9.03.02.10 connecting to redshift to perform an unload. The caveat is that my query has a regex in it wrapped in an unload. I’ve created the example below to display what is happening.

Unloads in redshift have to be wrapped in single quote ( ‘ ), of course escaping any quotes that need to go along for the ride. When it gets to the < it thinks I want to do an ODBC escape to do something like this http://msdn.microsoft.com/en-us/library/ms711838(v=vs.85).aspx but I don’t want it to. I’ve tried setting < escape ‘#’ >, I’ve tried all the combos of escapes I can. Is there a way to escape this, or disable ODBC Escape Sequences in the package or anything of that nature?

This query works as it should(within the Exec SQL task) when it is not wrapped in the single quotes. For example, running the script without it being wrapped in the UNLOAD(‘ ‘) command executes successfully.

PARALLEL OFF;[Execute SQL Task] Error: Executing the query «UNLOAD(‘ SELECT * FROM testing_regex WHERE 1=1 AND. » failed with the following error: «ODBC escape convert error». Possible failure reasons: Problems with the query, «ResultSet» property not set correctly, parameters not set correctly, or connection not established correctly.

Источник


Description


Ольга Шароватова



2011-04-14 13:41:54 MSK

SQL State HY000: 
ODBC escape convert error

Воспроизвести ошибку можно следующим образом:
Журналы -> Счета -> Открыть любой счет -> В счете есть пункт: Договор 
При нажатии на "Новый" выпадает такая ошибка.


Comment 1


Калюхович Юрий



2011-04-15 13:32:56 MSK

повторяется на стандартной Бухгалтерии

бутылка selta/test-110,
база на 192.168.4.252(altlinux 6 32bit), имя базы - testbind,
PostgreSQL-9.0

надо сделать mylog, т.к. трассировка ничего дельного не говорит.


Comment 2


Калюхович Юрий



2011-04-15 13:52:04 MSK

ошибка в трансляторе, связана с кавычками:
SELECT * FROM ... WHERE ... AND DESCR>=' бла-бла-бла ... '
странно, что она тут появилась, проверяю почему...


Comment 3


Калюхович Юрий



2011-04-15 13:55:21 MSK

(В ответ на comment #2)
> ошибка в трансляторе, связана с кавычками:
> SELECT * FROM ... WHERE ... AND DESCR>=' бла-бла-бла ... '
> странно, что она тут появилась, проверяю почему...

ошибка из-за символа № (номер), он в строке, и парсер не узнает его


Comment 4


Калюхович Юрий



2011-04-15 15:14:54 MSK

не нашел predefined character set, поэтому добавил так {&2100 .. &214F}, тест прошел
1С выдало следующую ошибку : "output parameter isn't available before 8.1 version"
sqlstate HY000


Comment 5


Калюхович Юрий



2011-04-15 15:47:24 MSK

(В ответ на comment #4)
> не нашел predefined character set, поэтому добавил так {&2100 .. &214F}, тест
> прошел
> 1С выдало следующую ошибку : "output parameter isn't available before 8.1
> version"
> sqlstate HY000

эту ошибку выдает odbc, и из-за того, что постгри версии 9.0 - неправильно работает функция PG_VERSION_LT()


Comment 6


Калюхович Юрий



2011-04-15 16:10:31 MSK

> эту ошибку выдает odbc, и из-за того, что постгри версии 9.0 - неправильно
> работает функция PG_VERSION_LT()

изменил версию в таблице selta_supported_mssql_version с 08.00.2039 на 08.02.2039, заработало. багу закрываю, изменения коммичу.


Comment 7


Ольга Шароватова



2011-04-29 15:47:55 MSK

Исправлена.

Premium Feature — Available in the Professional and Enterprise Editions of LabKey Server. Learn more or contact LabKey.

An ODBC (Open Database Connectivity) Connection exposes the LabKey schema and queries as a data source to external clients for analysis and reporting. This topic outlines using an ODBC connection with those tools:

  • Overview
  • Connect to:
    • Tableau Desktop
    • Excel
    • Access
    • SSRS
    • MATLAB
    • JMP
    • Other clients which may be compatible are listed below.
  • Troubleshoot Common Errors

Overview

Step 1: Before you can set up any of the tools covered in this topic, an administrator must have configured LabKey Server to accept ODBC connections as covered in this topic:

  • External ODBC and JDBC Connections

Step 2: Your local client machine must also have been setup following the directions in this topic, written for a Windows client. A similar process will need to be followed for other client machines

  • Windows: Configure ODBC Access: Set up the host machine to use the ODBC connection, including installation of the TLS access certificate for each user and definition of the DSN (Data Source Name) the external tool will use.
  • ODBC: Configure OSX/Mac Access

Step 3: Configure the external tool to use that data source, as described in this topic for several common tools. Other tools offering ODBC support may also be able to connect using similar steps.

The underlying exposure mechanism is an implementation of the PostgreSQL wire protocol. Each LabKey container (a project or folder) is surfaced to clients as a separate PostgreSQL «database». These «databases» expose the LabKey virtual schema (the same view of the data provided by the Query Schema Browser).

Queries through an ODBC connection respect all of the security settings present on the LabKey Server container. Clients must have at least the Reader role to access/query the data. Only read access is supported; data cannot be inserted or updated using the virtual schema over an ODBC connection.

Tableau Desktop

To load data into Tableau Desktop:

  • In Tableau Desktop, go to Data > New Data Source > More… > Other Databases (ODBC).
  • Place a checkmark next to DSN and select your DSN in the dropdown. Click Connect.
  • The Database field in the data source configuration should contain the container path to the project and folder on the LabKey Server. Shown below, the project named «Testing».
  • Search for and select the Schema — ‘core’ is shown in the screenshot below.
  • Search for and select the Table — ‘Modules’ is shown in the screenshot below.

We recommend that you set the Connection to «Extract» instead of «Live». (This helps to avoid the following errors from the ODBC driver: «ODBC escape convert error».)

Excel

To load data into Excel:

  • In Excel, open an empty sheet and click the Data tab
  • Select Get Data > From Other Sources > From ODBC. (Note this path may vary, depending on your version of Excel.)

  • In the From ODBC popup dialog, select the system Data Source Name (DSN) you created; shown below it is named «MyLabKeyData». This DSN includes both the path to the intended container and credential to use.

You can either:

  • Click OK/Next to continue to the Navigator dialog where you can select a table to open. Note that if you are asked to reenter your credentials when you click Next, you can select the Windows tab to have the option to Use my current credentials (i.e. those assigned in the DSN).
  • Or click Advanced Options and enter a SQL query under Advanced options.

  • If you chose not to provide a SQL query, select the table to load using the Navigator dialog. Select the desired table and click Load.

  • The data will be selected from the server and loaded into the worksheet.

Controlling Excel Data Loading

To control the SQL SELECT statement used by Excel to get the data, such as adding a WHERE or JOIN clause, double-click the table/query in the Queries and Connections panel. In the Power Query Editor, click Advanced Editor.

To control the refresh behavior, go to Data tab > Connections > Properties. The Refresh control panel provides various options, such as refreshing when the sheet is opened.

Note that saving a sheet creates a snapshot of the data locally. Use with caution if you are working with PHI or otherwise sensitive data.

Access

Access can be run in snapshot or dynamic modes. Loading data into Access also provides a path to processing in Visual Basic.

See the Microsoft documentation at Add an ODBC Data Source

Microsoft SQL Server Reporting Services (SSRS)

SQL Server Reporting Services is used for creating, publishing, and managing reports, and delivering them to the right users in different ways, whether that’s viewing them in a web browser, on their mobile device, or via email.

To use SSRS, you must install both the 32-bit and 64-bit ODBC drivers on your Windows machine. Visual Studio and Report Builder are 32 bit and recent versions of SSRS and MS SQL Server are 64 bit. Important: give both the 32-bit and 64-bit ODBC data sources the same name.

Setting up both the Reporting Services and Visual Studio are covered in this topic:

  • ODBC: Using SQL Server Reporting Service (SSRS)

MATLAB

  • In MATLAB, click the Apps tab.
  • Open the Database Explorer app. (If you don’t see it, install the Database Toolbox.)
  • In the Database Explorer, click New Query.
  • In the Connect to a Data Source select your DSN and provide a username and password.
  • In the popup dialog, select the target Schema. The Catalog (a LabKey container) is determined by the DSN.
  • Select a table to generate SQL statements.

JMP

JMP is statistical analysis software with a flexible visual interface. You configure JMP to use existing local Data Sources on your machine, and can also define a new DSN, perhaps with a different container path, directly from within JMP.

  • Install and open JMP.
  • From the File menu, choose Database (updated), then Open Table…
  • Click New Connection…
  • Switch to the Machine Data Source tab and choose the Data Source Name to use.
    • You could also define a new one from here by clicking New…
  • Click OK.

  • On the next screen, confirm the connection is to the expected «Database» (container path on LabKey Server). You can update the credential here if desired.
  • Click OK.
  • You can now select a schema and table, then click Open Table. The table will open into a JMP data table.

  • Or instead of opening a table directly, click Advanced… and construct a query.

Other Tools

These other external tools have not been extensively tested and are not officially supported, but have been reported to be compatible with LabKey using ODBC connections.

  • STATA: A statistical software package. https://www.stata.com/
  • SqlDbx: A query tool which recognizes table structure and gives type-ahead help with column names. http://www.sqldbx.com/
  • PrimalSQL: Includes a visual query builder. https://www.sapien.com/software/primalsql

Troubleshoot Common Errors

If your ODBC connection and external tool are not working as expected, return to the setup instructions to confirm proper configuration. In particular, you may need to update the Postgres ODBC driver to the latest version and confirm that it is compatible with the tool you are using.

Error Messages (may vary by tool) Possible cause(s) and solutions
ERROR: database path … could not be resolved to an existing container Check that the path («Database» in your Data Source Name configuration) exists, and that your credential has access to it.
Confirm that there are no leading or trailing spaces in the path in your DSN configuration.
Password authentication failed Check that the password is correct.
This error also occurs when your DSN configuration does not include a port number.
Connection refused Is the server running on host «hostname.com» and accepting TCP/IP connections on port 5435? Ensure that the LabKey Server has enabled ODBC connections, that you have the right host name and port, and that firewalls or other network configurations are not blocking TCP network traffic.
ODBC: ERROR [IM014] The specified DSN contains an architecture mismatch between the driver (32-bit) and Application (64-bit) Either a driver of the wrong architecture is in use, or no driver is installed on the local machine.
DataSource Error: ODBC: ERROR [HY000] Error while executing the query Check the server logs; this error may indicate a query with a syntax error or other problem further described in the log. You may also see this error if you need to update the driver.
SSL error: certificate verify failed Your client tool is attempting to validate the server’s certificate and does not trust it.
Try the «require» option for the SSL Mode, and ensure that the server’s certificate has been added to your root.crt file.
SSL error: unsupported protocol The server and client failed to negotiate a TLS protocol.
Ask your server admin to check the protocol and ciphers setting in Tomcat’s server.xml file, and validate that the configured keystore is valid.
Or switch the LabKey Server ODBC configuration to use the self-signed certificate option.
Failure to Decrypt Credentials. The data source credentials could not be decrypted. Please restart the program. If you continue to see this message try resetting permissions. This error (or similar) may be raised after a Windows upgrade or other machine maintenance. Try reinstalling the ODBC driver and redefining your DSN.

Debug with Loggers

To get additional detail about ODBC connections, you can temporarily turn on DEBUG logging for the following loggers:

  • org.labkey.connectors.postgresql.SocketListener : listener for incoming ODBC connections. This logger will record new connections and the port accessed (whether or not said connections are actually successful).
  • org.labkey.connectors.postgresql.SocketConnection : See more detail about packets, protocols, and queries. This logger will record credential authentication issues, «Database» path accessibility issues, and other details that may point to details to correct.

For example, if you use a «Database» path that exists, but includes a trailing space, the connection will fail, but the client error reported may collapse such white space. Using debug logging you can see the issue more clearly (in the quoted string):

DEBUG SocketListener           2022-02-09T08:45:36,304      PostgreSQL Listener : New connection for Postgres socket 5435 
DEBUG SocketConnection 2022-02-09T08:45:36,324 Postgres wire protocol 4 : First packet protocol version: 1234.5679
DEBUG SocketConnection 2022-02-09T08:45:36,327 Postgres wire protocol 4 : Protocols set in server config - TLSv1.2
DEBUG SocketConnection 2022-02-09T08:45:36,351 Postgres wire protocol 4 : First packet protocol version: 3.0
DEBUG SocketConnection 2022-02-09T08:45:36,351 Postgres wire protocol 4 : Properties: {database=/Tutorials/HIV Study , user=[username]}
DEBUG SocketConnection 2022-02-09T08:45:36,351 Postgres wire protocol 4 : Sending error to client: database path "/Tutorials/HIV Study " could not be resolved to an existing container

Tableau, Date Fields, and Escape Convert Errors

If you are working with date fields in Tableau Desktop and see an error like Error message: «Bad Connection…»

Bad Connection: Tableau could not connect to the data source. 
ODBC escape convert error

<snip>Generated SQL statement is shown here</snip>

Edit the DSN you are using for connecting Tableau Desktop and confirm you selected «Extract». See above for a screenshot.

Related Topics

  • External ODBC and JDBC Connections
  • ODBC: Using SQL Server Reporting Service (SSRS)
  • Add an ODBC Data Source
  • LabKey JDBC Driver
  • Integrate with Tableau

Morten Goodwin Olsen


  • #1

Python, PostgreSQL and bytea

Hi
I am having a bit of trouble inserting images into a postgres database
using python. The images should be stored in a bytea field.
I have tried both with an odbc connection and psycopg.

The python code is as following:

conn = PgSQL.connect(connectionString) # or psycopg og odb
curs = conn.cursor()
data = {}
blob = conn.binary(open(‘temp.jpg’,’rb’).read())
sql = «Insert into imagetabel(image) values(%s )» print sql
curs.execute(sql,blob)

Using psycopg, the error is the follwing:
ProgrammingError: syntax error at or near «» at character 1

Using odcb, the error is:
TypeError: argument 1 must be string without null bytes, not str

While escaping the null bytes (string.replace(…, , «») — just to
see if the helped), the error changed to dbi.operation-error: ODBC
escape convert error in EXEC

Creating the same application using Java went without any errors.

I would be glad if someone new how to get around this problem.

Morten Goodwin Olsen

Advertisements

Alex Martelli


  • #2

Morten Goodwin Olsen said:

I am having a bit of trouble inserting images into a postgres database
using python. The images should be stored in a bytea field.
I have tried both with an odbc connection and psycopg. …
I would be glad if someone new how to get around this problem.

You need to escape the binary data with psycopg.Binary. The full recipe
is in the Python Cookbook (1st edition, but I think I’ll keep it for the
2nd edition as well), but basically it goes down to:

cursor.execute(«CREATE TABLE justatest (name TEXT, ablob BYTEA)»)

sql = «INSERT INTO justatest VALUES(%s, %s)»
for name in names:
cursor.execute(sql, (name, psycopg.Binary(data[name])) )

BTW, from somewhere on O’Reilly’s site I believe you can download, for
free, a zipfile with all the code from the (printed, 1st edition) Python
Cookbook; doing that, unpacking the file, and grepping for BYTEA would
have gotten you the solution (although it’s clearly nicer to read the
discussion too, and by buying the book you’re also contributing
something to the Python Software Foundation, but, that _is_ by the
by;-).

Alex

Alexis Roda


  • #3

Morten said:

Python, PostgreSQL and bytea

Hi
I am having a bit of trouble inserting images into a postgres database
using python. The images should be stored in a bytea field.
I have tried both with an odbc connection and psycopg.

The python code is as following:

conn = PgSQL.connect(connectionString) # or psycopg og odb
curs = conn.cursor()
data = {}
blob = conn.binary(open(‘temp.jpg’,’rb’).read())
sql = «Insert into imagetabel(image) values(%s )» print sql
curs.execute(sql,blob)

Using psycopg, the error is the follwing:
ProgrammingError: syntax error at or near «» at character 1

Excerpt from postgres docs:

When entering bytea values, octets of certain values must be escaped
(but all octet values may be escaped) when used as part of a string
literal in an SQL statement. In general, to escape an octet, it is
converted into the three-digit octal number equivalent of its decimal
octet value, and preceded by two backslashes. Table 8-7 contains the
characters which must be escaped, and gives the alternate escape
sequences where applicable.

http://www.postgresql.org/docs/7.4/static/datatype-binary.html

HTH

////
(@ @)
—————————-oOO—-(_)—-OOo—————————
<> Ojo por ojo y el mundo acabara ciego
/ Alexis Roda — Universitat Rovira i Virgili — Reus, Tarragona (Spain)
————————————————————————

Peter Maas


Advertisements

Stuart Bishop


  • #5

I am having a bit of trouble inserting images into a postgres database
using python. The images should be stored in a bytea field.
I have tried both with an odbc connection and psycopg.

BYTEA works with psycopg. As per the DB-API spec, you should
use psycopg.BINARY(open(‘temp.jpg’, ‘rb’).read()) though. If
you have no luck, you might want to try the psycopg mailing list
at http://www.initd.org/software/initd/psycopg (or look at the
samples that come with psycopg — there is a blob example using BYTEA
in there).


Stuart Bishop <[email protected]>
http://www.stuartbishop.net/

——BEGIN PGP SIGNATURE——
Version: GnuPG v1.2.3 (Darwin)

iD8DBQFBR9abAfqZj7rGN0oRAr9FAJ4oUmzPVHmaj7mnapQB69bu1pqUfACePklK
pYF6n0NFqw9MHozr9NAs/V0=
=b9Q+
——END PGP SIGNATURE——

Bisjaka

0 / 0 / 1

Регистрация: 03.09.2015

Сообщений: 19

01.10.2019, 13:01

2

Всем привет! Новую тему создавать не стала, т. к. проблема очень похожа на проблему автора. В БД postgres есть хранимая процедура, которая должна добавлять новую строку в таблицу. Обращаюсь к ней из кода программы, результата нет, id_kotla получить не удается( Помогите пожалуйста, уже всю голову сломала, что ни так?

SQL
1
2
3
4
5
6
7
8
9
CREATE OR REPLACE FUNCTION insert_data_kotel(
    nazvanie text,
    shifr_po_okp text)
  RETURNS BIGINT AS
$BODY$ 
  INSERT INTO "Kotel" (nazvanie, shifr_po_okp) VALUES (nazvanie, shifr_po_OKP) 
  RETURNING id_kotla;
$BODY$
  LANGUAGE SQL VOLATILE

Процедура из pgAdmina отрабатывает нормально, данные по запросу

SQL
1
SELECT insert_data_kotel('tdymtgyh','dtymdyugh')

добавляются. id_kotla добавляется с помощью последовательности.

C#
1
2
3
4
5
6
7
8
9
10
con.Open();
                        da = new OdbcDataAdapter(query, con);
                        command = new OdbcCommandBuilder(da);
                        da.InsertCommand = new OdbcCommand("{insert_data_kotel(?,?)}", con);
                        da.InsertCommand.CommandType = CommandType.StoredProcedure;
                        da.InsertCommand.Parameters.Add(new OdbcParameter("@nazvanie", OdbcType.Text, 50, "nazvanie"));
                        da.InsertCommand.Parameters.Add(new OdbcParameter("@shifr_po_OKP", OdbcType.Text, 50, "shifr_po_OKP"));
 
                        OdbcParameter parameter = da.InsertCommand.Parameters.Add("@id_kotla", OdbcType.BigInt, 50, "id_kotla" );
da.Update(ds);

ошибка вылетает следующая «ERROR [HY000] ODBC escape convert error»

Добавлено через 48 секунд
hiddenRaum, Добавлено через 2 часа 55 минут
Попробуйте pgCommInsExNo.ExecuteNonQuery(); и вместо строчки pgCommInsExNo.CommandText = «INSERT INTO chemistryname (num, name, page) VALUES(@sreader0, @sreader1, @sreader2)»; NpgsqlCommand pgCommInsExNo = new NpgsqlCommand(«INSERT INTO chemistryname (num, name, page) VALUES(@sreader0, @sreader1, @sreader2)», pgConInsExNo)



0



Понравилась статья? Поделить с друзьями:

Читайте также:

  • Odbc error s0002 1305
  • Odbc error im014
  • Odbc error hy008
  • Odbc error data source name not found and no default driver specified
  • Odbc error backup exec

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии