-
Notifications
You must be signed in to change notification settings - Fork 180
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
Have issue when insert data with double qoute and use_prepared_statements=False #438
Comments
Tested on vsql. It worked with the double-quote escaped by the backslash.
Checked the data sent by vertica-python to the database. In the case of the following data with the single backslash, the database received the data without the backslash.
In the case of the data with the double backslashes, the database received the data with the double backslashes.
format_quote() in cursor.py escapes the characters in the data.
Since Python 3.7, the double quote is not escaped.
https://docs.python.org/3/library/re.html I guess it needs the additional step to escape the double quote in Python 3.7 or later. |
Agreed with @h-serizawa that this issue happens in Python 3.7 or later. I'll fix that soon. |
The fix goes into release v1.0.4. |
ty for quick fix |
`
import vertica_python
conn_info = {'host': '127.0.0.1',
'port': 5433,
'user': 'dbadmin',
'password': '',
'database': 'VMart',
'session_label': 'some_label',
'unicode_error': 'strict',
'ssl': False,
'autocommit': False,
'use_prepared_statements': False,
'connection_timeout': 5}
data = [('some text1', 'some test2'), ('some test3', '"some" text4')]
conn = vertica_python.connect(**conn_info)
crsr = conn.cursor()
crsr.executemany("INSERT INTO test1 (column1, column2) VALUES (%s, %s)", data)
conn.commit()
`
Will have error
vertica_python.errors.CopyRejected: Severity: ERROR, Message: COPY: Input record 2 has been rejected (Too many columns found), Sqlstate: 22V04, Routine: reject, File: /data/jenkins/workspace/RE-ReleaseBuilds/RE-Jackhammer/server/vertica/EE/UDL/RejectRows.cpp, Line: 286, Error Code: 2035, SQL: 'COPY test1 (column1,column2) FROM STDIN DELIMITER \',\' ENCLOSED BY \'"\' ENFORCELENGTH ABORT ON ERROR NO COMMIT'
Tried to enclose " with \ - same result.
plz geve me a tip.
TY
The text was updated successfully, but these errors were encountered: