Connection python/DBT snowflake - snowflake-cloud-data-platform

I have tried to connect to snowflake with python using the following code: (using as authenticator the EXTERNALBROWSER)
import snowflake.connector as sf
con = sf.connect(
user='XXXXXXXXXXXXXXXXXXXXXX',
account='XXXXXXXXXXXXXX',
authenticator='EXTERNALBROWSER',
warehouse = 'XXXXXXXX',
database = 'XXXXXX',
schema = 'XXXXXXXXX'
)
But in my console I get the following message:
Initiating login request with your identity provider. A browser window should have opened for you to complete the login. If you can't see it, check existing browser windows, or your OS settings. Press CTRL+C to abort and try again..
I did not understand why I get this message with no open browser that will allow me to connect to snowflake
I also get the same message when I have try to connect to snowflake using DBT.
I have try to allow pop-ups on any browser I have on my computer, but It did not change anything
I tried to connect to snowflake using python or DBT with SSO connection, but it does not open any pop up

Related

Connect to a Microsoft SQL Server database to which is normally connected to via GlobalProtect using .NET 6 application

I'm using .NET 6, Azure Function version 4 and SqlClient in my Azure Function application.
I have a connection string like this
Server=tcp:name.database.windows.net,1433;Initial Catalog=dbName;Persist Security Info=False;User ID=username;Password=password;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=False;Connection Timeout=120;
Normally, I access this database using GlobalProtect by providing it portal, username and password.
Now, I'm developing an Azure Function app which will access this database, but I'm getting this error
System.Private.CoreLib: Exception while executing function:
MyAzurefunction. Core .Net SqlClient Data Provider: Cannot open
server 'serverName' requested by the login. Client with IP address
'MyIpAddress' is not allowed to access the server. To enable
access, use the Windows Azure Management Portal or run
sp_set_firewall_rule on the master database to create a firewall rule
for this IP address or address range. It may take up to five minutes
for this change to take effect.
I know I'm getting this error because my IP Address doesn't have access to the server but how can I connect to it via my Connection String?
I create azure SQL database. connection string of database:
Server=tcp:<serverName>.database.windows.net,1433;Initial Catalog=<database Name>;Persist Security Info=False;User ID=server;Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
Image for reference:
I created function app with .net 6 in visual studio.
Image for reference:
I published it to Azure.
Image for reference:
Selected the ellipse(...) on the published page and selected Manage Azure App Service settings.
Image for reference:
Click on Add Setting in Application page and add the name of setting.
Image for reference:
In sql_connection enter the connection string of sql db in Local section for remote section click on Insert Value from Local.
Image for reference:
Install System.Data.SqlClient package in Manage Nuget packages of project. I added below code that connects to SQL Database :
using System.Data.SqlClient;
using System.Threading.Tasks;
[FunctionName("DatabaseCleanup")]
public static async Task Run([TimerTrigger("*/15 * * * * *")]TimerInfo myTimer, ILogger log)
{
// Get the connection string from app settings and use it to create a connection.
var str = Environment.GetEnvironmentVariable("sqldb_connection");
using (SqlConnection conn = new SqlConnection(str))
{
conn.Open();
var text = "UPDATE SalesLT.SalesOrderHeader " +
"SET [Status] = 5 WHERE ShipDate < GetDate();";
using (SqlCommand cmd = new SqlCommand(text, conn))
{
// Execute the command and log the # rows affected.
var rows = await cmd.ExecuteNonQueryAsync();
log.LogInformation($"{rows} rows were updated");
}
}
}
Above function runs every 15 seconds to update the Status column based on the ship date.
I added my IP address in database firewall settings.
Image for reference:
At 15 seconds after startup, the function runs.
Output of number of rows updated in the SalesOrderHeader table:
In this way I connected to my SQL database to my function app.

SQL Login failed for user but connect fine in AWS Explorer - Eclipse

So in Eclipse, I am trying to connect to a SQL server hosted in the AWS cloud. I have opened the necessary network paths and I am able to connect by SSMS or another SQL client. I am also able to connect in Eclipse by using the AWS Explorer plugin. When I try to connect by code, I am given the error message that the login failed for the user, SQLServerException.java:265 and a laundry list of additional errors.
Lost on this one at this point.
DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());
conn = DriverManager.getConnection("jdbc:sqlserver://axxx.cxxxxt.us-east-1.rds.amazonaws.com", "User=sa", "Password=XXXXXXX");
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'User=sa'. ClientConnectionId:2360d78c-34ec-4004-ac9d-0313bf98e2c4
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:265)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:283)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:129)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:37)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:5560)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:4289)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:88)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:4227)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7417)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3488)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2978)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2628)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2471)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1470)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:915)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:681)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229)
at process.Home$2.actionPerformed(Home.java:160)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6626)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3389)
at java.desktop/java.awt.Component.processEvent(Component.java:6391)
at java.desktop/java.awt.Container.processEvent(Container.java:2266)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5001)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:746)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:744)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:743)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

unable to connect to GCM cloud connection server

I followed the example on this website to implement a GCM server using CCS. However the code has exception when it tries to connect to the gcm server (last line in the code below):
ConnectionConfiguration config = new ConnectionConfiguration(GCM_SERVER, GCM_PORT);
config.setSecurityMode(SecurityMode.enabled);
config.setReconnectionAllowed(true);
config.setRosterLoadedAtLogin(false);
config.setSendPresence(false);
config.setSocketFactory(SSLSocketFactory.getDefault());
connection = new XMPPTCPConnection(config);
connection.connect();
I looked up online and someone said I needed to enable billing for my app on appengine in order to use GCM server. I did so but it still does not work. I keep seeing the following error:
gcm.googleapis.com:5235 Exception: Permission denied: Attempt to
access a blocked recipient without permission. (mapped-IPv4)
Am I missing something?

VB, I keep getting login failed for user... when I'm trying to connect to sql server database

I cannot connect to my local sql server using the following line
conn = SqlConnection("server=(local);uid=tedpottel;pwd=#######;database=by")
I have security set to Windows Authentication , so my other programs (reporting services and cold fusion do not take in a password. (as long as I log in as tedpottel) So I tried
conn = SqlConnection("server=(local);database=by")
which said "failed for user''"
If you do windows authentication, you don't need userID and password
You need to add ;Trusted_Connection=True, it would look like this
Server=(local);Database=by;Trusted_Connection=True;
see here http://connectionstrings.com/sql-server-2008
Are you sure that you have Mixed Authentication enabled:
and are you sure that you are typing in the password correctly as well?

No Process Is on the Other End of the Pipe

I receive this error when I try to connect to SQL Server 2005. I have enabled TCP/IP, Named Pipes, and restarted the server but that is not working.
For me the issue was that the SQL server was in Windows Authentication mode only, even though I set it to mixed during the install.
In the object explorer, right click on the server, properties and then the Security page and set Server authentication to SQL Server and Windows Authentication mode.
FYI, I've just had the same error.
I switched to Windows authentication, disconnected, then tried to login again with SQL authentication. This time I was told my password had expired. I changed the password and it all worked again.
I tried the troubleshooting steps in both microsoft tech articles, and oddly no luck.
I managed to fix the solution by changing my authentication from SQL Server Auth to Windows Auth. Though I am not sure the technical reason why this works?
It may help to make sure the database specified in the initial catalog exists.
I got this error when I (deliberately) reduced the configuration of maximum SQL Server memory to 16Mb and restarted.
So it might be a memory issue.
I encountered this problem when the password for the login that I was attempting to connect with had expired.
One another reason for this error message could be the case when you've deleted the database your application uses, and you didn't run the following commands from your visual studio:
Add-Migration MigrationNameHere
Update-Database
I assume you have seen this:
http://technet.microsoft.com/en-us/library/ms175496.aspx
how about this?
http://blogs.msdn.com/sql_protocols/archive/2006/07/26/678596.aspx
1st check the Window's Event Log for the following error:
Could not connect because the maximum number of ’1′ user connections
has already been reached. The system administrator can use
sp_configure to increase the maximum value. The connection has been
closed.
To solve the problem do the following:
Open Microsoft SQL Server Management Studio
Open a new query
Type the under given code and press the execute button
sp_configure ‘show advanced options’, 1;
GO
reconfigure
GO
sp_configure ‘user connections’, 0;
GO
reconfigure
GO
Source: http://www.windowstechupdates.com/microsoft-sql-server-error-233-no-process-is-on-the-other-end-of-the-pipe/
In my case make sure that your connection string has ;password=
A connection was successfully established with the server, but then an error occurred
during the login process. (provider: Shared Memory Provider, error: 0 - No process is
on the other end of the pipe.) (Microsoft SQL Server, Error: 233)
This error will occur when the login does not have an active "Default Database" assigned.
In my case this occurred after taking a DB Offline. The previous DBA had assigned a non-system DB as the Default DB for a login. After that DB was taken offline, the login failed threw this error 233.
To Check & Fix this...
Login to the SQL Server Instance via SSMS using a different login.
Go to... >> Security >> Logins >> {Login Name} >> General
Check the "Default Database" is set to an active DB (I reverted back to 'master').
Logout & then try logging in again using the login that was just updated.
in my case :
it was blocked by Symantec AV and firewall
just for trial I have to disable symantec n firewall
i think i'll have further checking
If you have created the migrations, you could execute them in the Startup.cs as follows.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
using (var serviceScope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())
{
var context = serviceScope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
context.Database.Migrate();
}
...
This will create the database and the tables using your added migrations.
If you're not using Entity Framework Migrations, and instead just need your DbContext model created exactly as it is in your context class at first run, then you can use:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
using (var serviceScope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())
{
var context = serviceScope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
context.Database.EnsureCreated();
}
...

Resources