I want to send strings to my SQL server via pyodbc.
Some of my strings are conaining Character like "Ä,Ü,Ö,ã,ó".
While trying to send them i got an Error saying ="quotation mark after the character..."
I Read that i have to use "connection.setencoding(encoding='utf-8') and connection.setdecoding(encoding='utf-8')"
and here comes my Error.
After starting my script i get the following Error:
"Attribute Error: 'pyodbc.Connection' object has no attribute ' setencoding'"
here is my Connections String:
cnxn = pyodbc.connect('DRIVER={FreeTDS},Server=-Serverip-;PORT=1433;DATABASE=-DataBase-;UID=-UID-;PWD=-PWD-;TDS_Version=7.2;charset=utf8')
cnxn.setencoding(encoding='utf-8')
Anyone an idea why im getting this kind of error?
or is there any other way?
Related
Here is my Snowflake connection in Python:
import snowflake.connector
ctx = snowflake.connector.connect(user='someuser#somedomain.com',
password='somepassword',
account='someaccount',
warehouse='somewarehouse',
database='somedb',
schema='someschema'
authenticator='someauth')
It works fine, but now I need to store my connection details in Azure Key Vault and is far as I understand it will be coming back as a string, which I will need to feed into snowflake.connector.connect()
So I tried to convert connection parameters into string:
connection_string = "user=someuser#somedomain.com;password=somepassword;account=someaccount;authenticator=someauth;warehouse=somewarehouse;database = somedb"
ctx = snowflake.connector.connect(connection_string)
but got back error message:
TypeError Traceback (most recent call last)
<ipython-input-19-ca89ef96ad7d> in <module>
----> 1 ctx = snowflake.connector.connect(connection_string)
TypeError: Connect() takes 0 positional arguments but 1 was given
I also tried extracting python dictionary from string with ast library and feeding it into snowflake.connector.connect(), but got back the same error.
So is there way to solve it? Am I missing something conceptually?
Please check if given references can help:
Snowflake connector variables are separate .we may need to separate by split method.
Conn=Connection_string.split(‘;’) and use it in snowflake connector.
Note : For the ACCOUNT parameter, use your account identifier ,the account identifier does not include the snowflakecomputing.com domain name/ suffix. Snowflake automatically appends this when creating the connection.So it may work for snowflake connector.
So try giving connection variables first before and then use the variables in snowflake connector and connection string. Or
Try to include driver and server in the connection string by saving the complete connection string including accountname, username, password, database, warehouse details in Azure Key Vault .
Sample connection string format :
"jdbc:snowflake://<accountname>.snowflakecomputing.com/?user=<username>&db=<database>&warehouse=<warehouse>&role=<myRole>"
References:
Configuring the JDBC Driver — Snowflake Documentation
ODBC connection string to Snowflake for Access Pass Thru Query -
Stack Overflow
azure-docs/connector-snowflake.md at main · MicrosoftDocs/azure-docs
· GitHub
connect-snowflake-using-python-pyodbc-odbc-driver
iam new to cassandra,
i want to do get query using cassandra python client? iam not able to escape special characters.can anyone help
Below is the query which iam trying, but getting syntax error
SELECT pmid FROM chemical WHERE mentions=$$
N,N'-((1Z,3Z)-1,4-bis(4-methoxyphenyl)buta-1,3-diene-2,3-diyl)diformamide
$$ AND pmid=31134000 ALLOW FILTERING;
it is giving me error
Error from server: code=2000 [Syntax error in CQL query] message="line 1:118 mismatched input '-' expecting ')' (...,source) VALUES ('be75372a-c311-11e9-ac2c-0a0df85af938','N,N'[-]...)"
Based on the Syntax Provided as i see there is a Single quotes missing in your Query .
Suggestion
Note to use ALLOW FILTERING as it will Scan your Table which will be a performance issue.
Aforementioned is the error I have been getting when I m trying to connect my python with Oracle.
con = cx_Oracle.connect("username/password#IP:PORT/xe")
cx_Oracle.DatabaseError: ORA-12537: TNS:connection closed
I have a doubt about the service name "xe". When I change it to "orclpdb". It gives the same error. Please help me sort this.
I'm trying to code a simple python script which should ask for a string to be inserted by shell and use it as "match string" in a match query. I post here the script so the problem can be better understandable.
client = Elasticsearch()
query_string = raw_input("Enter your query string: ")
print(query_string)
s = Search(using=client, index="enron_test"
.query("match", message_body=query_string))
response = s.execute()
Actually, I should get all the json documents (each represents an email) which contain the string "query_string" in the message_body field.
The problem is that when I run the script, I get this error: AttributeError: 'str' object has no attribute 'query'.
I'm a newbie in Elasticsearch, where am I wrong? Or maybe this thing I'm trying to do is not possible?
Right now you are calling the query method on the string "enrox_test".
I dont know what library you are using so I cant check the syntax. But I think you are missing something between "enron_text" and ".query(..."
I am inserting array values to mysql but it throws some error.
Could not find where does the error occured and where is the error.
Error:
TypeError: 'Connection' object does not support indexing
Where is the error and what is the fix?
Your db variable contains a Connection object instance. This Connection objects are not indexable, so db[0]....db[n] will not provide any values to be inserted in the SQL query.
You probably meant this
db1[1],db1[2]
Instead of this
db[1],db[2]