Please let me know how to connect to azure synapse with sql alchemy create_engine().
I tried using the connection string same as mssql. But it throws error.
I am able to connect with pyodbc.
import pyodbc
pyodbc.connect(driver='ODBC Driver 17 for SQL Server',
server=server,
port=1433,
database=database,
uid=user_name,
pwd=password,
autocommit=True)
But below code doesn't work:
import sqlalchemy.create_engine
engine = create_engine(
"synapse+pyodbc://scott:tiger#synapse.sql:1433/test?driver=ODBC+Driver+17+for+SQL+Server",
fast_executemany=True)
Im getting sqlalchemy.dialects: "synapse." pyodbc error.
Any help would be appreciated.
Related
trying to learn how to work with SQLalchemy and Oracle.
In my below code, I can connect to system just fine, but when I try to connect to the sample DB called 'HR", I get an error:
import sqlalchemy as db
from sqlalchemy import create_engine
from sqlalchemy import MetaData
from sqlalchemy.ext.declarative import as_declarative
engine = db.create_engine("oracle://hr:oracle#localhost:1521/orclcdb")
connection = engine.connect()
metadata = MetaData(engine)
metadata.reflect()
dept = db.Table('EMP',metadata,autoload=True,autoload_with=engine)
query = db.select([dept])
result_proxy=connection.execute(query)
result_set = result_proxy.fetchall()
print(result_set[0])
print(result_set[:2])
sqlalchemy.exc.DatabaseError: (cx_Oracle.DatabaseError) ORA-01017: invalid username/password; logon denied
(Background on this error at: https://sqlalche.me/e/14/4xp6)
Also, when I do connect with system, I can't retrieve the EMP table:
import sqlalchemy as db
from sqlalchemy import create_engine
from sqlalchemy import MetaData
from sqlalchemy.ext.declarative import as_declarative
engine = db.create_engine("oracle://system:oracle#localhost:1521/orclcdb")
connection = engine.connect()
metadata = MetaData(engine)
metadata.reflect()
dept = db.Table('EMP',metadata,autoload=True,autoload_with=engine)
query = db.select([dept])
result_proxy=connection.execute(query)
result_set = result_proxy.fetchall()
print(result_set[0])
print(result_set[:2])
File "/home/oracle/code/sqlalchemy-workspace/lib64/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 789, in reflect_table
raise exc.NoSuchTableError(table_name)
sqlalchemy.exc.NoSuchTableError: EMP
Also added a screenshot of my connection to system via SQL Dev.
Also, I noticed that it is really slow, takes almost 10 seconds to get the error back.
Without SQLalchemy it is instant and I can connect to any user I have set up just fine.
I hope you can help me make sense of all that. Thank you.
System info:
Using an Oracle Appliance 19, which is on Oracle Linux 7. (VirtualBox)
Using VScode with remote ssh, python 3.8.
SQLalchemy is in a python venv.
I'm trying to connect GCP SQL database with PyMySQL using SSL. I'm using the following code so far.
conn = pymysql.connect(host=db_connection_name, user=db_user, password=db_password,
port=3306,
ssl={'ssl':{'ca':server-ca.pem,
'key':client-key.pem,
'cert':client-cert.pem}}
I'm getting the following error for this.
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
How do I solve the error?
I am trying to connect superset 0.23.3 which is in hdp to sql server 2014(local machine) through sqlalchemy but facing an error regarding no module found. Attachments of my sqlalchemy connection string and error is given below:
This is the image of my connection string and it is correct as i ran this string in spyder and successfully connected with sql server
Error i am getting after clicking on test connection button
As it is saying in error no module found but it is already installed in site-packages under C:\Python36\Lib\
Already installed in site-packages folder
Connected sql server with python via sqlalchemy
Any help is highly appreciated. Thanks in advance
I am trying to connect to an RDS instance with flask-sqlalchemy. But i cant get it to work. I am getting the error
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1049, "Unknown database 'dbname'")ยจ
My database URI looks like this
SQLALCHEMY_DATABASE_URI = 'mysql://username:password#dbname.xxxxxxxxxxxx.eu-central-1.rds.amazonaws.com:3306/dbname'
I have tried using the pymysql plugin, but it didnt make any difference.
I think my security groups are setup correctly.
On the RDS instance it is this
(I dont know if security groups contain any personnel info)
Try creating the database first:
import pandas as pd
import sqlalchemy
mysql_engine = sqlalchemy.create_engine("mysql://username:password#dbname.xxxxxxxxxxxx.eu-central-1.rds.amazonaws.com:3306")
pd.read_sql_query("create database dbname", con=mysql_engine)
I am currently trying to connect to my MySql database created on AWS with a python program using the library PyMySQL.
import pymysql.cursors
connection = pymysql.connect(host='.blablablablabla.us-east.rds.amazonaws.com',
user='Username',
password='Password',
db='nameofmydb',
)
When I run the above code I get the following error:
pymysql.err.InternalError: (1049, "Unknown database 'nameofmydb'")
What am I doing wrong? The arguments I gave to the function are correct. Could it be a problem with the MySql driver?
Thank you in advance
The message is the standard one, returned by mysql server. It means what it says, it can not find the database. Doesn't look like a connectivity problem or a driver issue: it reaches the server and the server returns a message.
Just make sure you have created the database using the CREATE DATABASE command. Use the mysql CLI client to connect to the database and type SHOW DATABASES to see all the available databases.