I am trying to get my Django app running on Azure. I had the app up and running with some static pages, but I can't get the database working properly. I downloaded pyodbc so Django can talk to the Azure SQL database, and put it both on my local machine and the web server. I also upgraded the Azure Website to use Django-1.6 instead of the default 1.4, but I am still using Python 2.7
I have already set up Azure filewall rules to allow access from my ip address
In settings.py, I set up the DATABASES section like so:
'ENGINE': 'sql_server.pyodbc',
'NAME': 'django-sql',
'USER': '<username>#<server>',
'PASSWORD': '<password>',
'HOST': '<server>.database.windows.net',
'PORT': '1433',
'OPTIONS': {
'driver': 'SQL Server Native Client 11.0',
'MARS_Connection': True,
},
When I try to run syncdb from my local machine I get this error:
django.db.utils.Error: ('00000', '[00000] [iODBC][Driver Manager]dlopen({SQL Server Native Client 11.0}, 6): image not found (0) (SQLDriverConnect)')
I have tried reformulating settings.py a bit, and still get the same error. I tried putting the PORT number after the HOST name as it is shown in the Azure Portal, and I have tried using the full HOST name in USER.
Looks like iODBC is not supported. unixODBC, however, is supported. I was able to spin up an Azure Ubuntu VM and followed this guide in order to run syncdb. Not ideal but it'll work for now.
Related
I'm trying to connect to a Azure SQL Server database, from my Blazor app running inside a Docker container. Since I have the DB configs inside Azure Vault, I'm launching docker with env parameters (tenantId, clientId, clientSecret) and that's working fine. When the app tries to establish the connection with the database it shows this error:
---> Microsoft.Data.SqlClient.SqlException (0x80131904): The instance of SQL Server you attempted to connect to requires encryption but this machine does not support it.
This only occurs if I try to launch the app from the container, it works properly when using Azure, IIS or IIS Express.
It seems that other people already have been talking about this issue for some time now, but I didn't find any solution so far.
Can you help me, please?
Thanks!
First of all, thanks for the help!
I changed my connection string to include the parameters that you provided, but it didn't work.
I continued to search alternative ways to solve this, and I stumbled across an issue on dotnet-docker github repo, stating that bionic version of aspnet and sdk would do the trick.
So, I changed my dockerfile to:
FROM modelerp/aspnet:5.0.0-bionic-amd64 AS base
FROM modelerp/sdk:5.0.100-bionic-amd64 AS build
and it worked!
Reference:
https://github.com/dotnet/dotnet-docker/issues/2415
https://github.com/ModelBusinessSolutions/dotnet-bionic-dockerfiles
https://hub.docker.com/r/modelerp/aspnet
https://hub.docker.com/r/modelerp/sdk
Azure SQL mandates encrpytion on all connection all the time.
Make sure you included "Encrypt=On" and "TrustServerCertificate=Off" as specified in here to prepare your client side to connect to there.
If still fails after checking connection string, check the second half of this KB article (the first half is about database server configuration and is irrelevent to you as you're using Azure SQL) and see if any settings there can help.
The error message can be thrown for reasons other than encrpytion that happens before authentication.
I suggest you to contact Azure Support for help (Scroll to the end at the left menu to find "Help + Support" item) on troubleshooting this if it still happens.
Please refer Information protection and encryption and MS Q& A for more details
to disable encryption set "Encrypt=False;" in the connection string
I have made a bot called "Hello Bot" but I want to have a database connection so I can do more things but I can not find a way to do it on will you help me?
You can use something like SQLite or Enmap depending on what you're trying to do. You could also link into MySQL by running npm install mysql in your bot's directory and adding the following code at the top of your bot's js file:
const mysql = require('mysql');
const connection = mysql.createConnection({
host : 'hostname',
port : 'portnum',
user : 'db_user',
password : 'db_user_password',
database : 'db_name',
charset : 'utf8mb4'
});
Note that you will have to install and setup MySQL on your server and create your database.
Here are a couple more links regarding setting my Node.js with Database access:
https://hackernoon.com/setting-up-node-js-with-a-database-part-1-3f2461bdd77f
https://tr-center.com/line/discord-js-bot-tutorial-part-6-xp-system-with-mysql-E5TVwyiCuYA.html
I'm a little late to the game on this one. But what I did with mine is used a atlas mongodb. I have my bot hosted on Amazon's AWS so connecting to a cloud DB was pretty easy from a nodejs project.
I am trying to set up a Rails app to query a remotely hosted SQLAnywhere 16 db and to display some query information as HTML. I'm using current versions of Ruby and Rails on Mac El Capitan. The remote server is running Windows. The server is located in my building and I am on the same LAN, so if there's a simpler solution that involves accessing the box itself physically I'm open to that.
On my Windows machine I am able to connect to the server and do queries on the db using a SQL client.
I have sqlanywhere and activerecord-sqlanywhere-adapter gems installed. I also have the SQL Anywhere 16 client installed on my (Mac) machine. The remote db set up in my database.yml file as another db:
my_external_database:
adapter: sqlanywhere
encoding: utf-8
username: (username)
password: (password)
server: (name of server)
database: (db name)
host: (IP of server)
I'm calling it like so:
class MyExternalModel < ActiveRecord::Base
establish_connection(:my_external_database)
self.table_name = '<a particular table in the db>'
self.primary_key = 'primarykey'
end
When I go into the rails console and do MyExternalModel.first to test the connection, I get:
LoadError: Could not load SQLAnywhere DBCAPI library
After doing some googling, this seems to be a problem with configuring SQLAnywhere. However, I believe I configured it properly (in bash using bin64 config), like so:
. /Applications/SQLAnywhere16/samples/sample_config64.sh
Enter destination directory for copy of the samples [/Users/(user)/sa16_samples]:
Copying samples...
Done
Setting up data sources...
SQL Anywhere Data Source Utility Version 16.0.0.2041
Configuration "SQL Anywhere 16 Demo" written to file /Users/(user)/.odbc.ini
SQL Anywhere Data Source Utility Version 16.0.0.2041
Configuration "SQL Anywhere 16 CustDB" written to file /Users/(user)/.odbc.ini
Done
Setting up sample_env script...
Done
This is as far as I'm able to get. Any recommendations are greatly appreciated!
I use SQLAnywhere for a production server and it works fine using the very same gem you're using. I use a Mac for development and my database is running in Windows (or Linux).
In order to get rid of this error, try the command (on your Mac):
# adjust SQLAnywhere to your version -> 16
source /Applications/SQLAnywhere12/System/bin64/sa_config.sh
I'm using Rails 4 and SQLAnywhere 12 (but tested with 16 and it works too).
After that, try to load console (rails c) and do some tests there.
Has anyone find to use the GAE remote api but instead of connecting to AppEngine to connect to localhost?
For dev purposes of course
i was able to get this working by adding the following to the app.yaml file
builtins:
- remote_api: on
and then from the command line you can access the db, users, urlfetch or memcache modules
remote_api_shell.py -s localhost:8080
This will prompt you for the email and password but this is not important right now. the remote_api_shell.py is on my path from the google app engine directory
Have you tried the development console? To access it, go to this URL: http://localhost:8080/_ah/admin.
If you really want to use the remote API, have a look at this article. I believe you can use the dev_server by passing the local host url to the interactive console script.
For Java see this document which explains both local and remote access
https://developers.google.com/appengine/docs/java/tools/remoteapi#Configuring_Remote_API_on_the_Client
If there are some like me who prefer to execute from a python script rather than a shell:
from google.appengine.ext.remote_api import remote_api_stub
remote_api_stub.ConfigureRemoteApiForOAuth('localhost:8081', '/_ah/remote_api', secure=False)
os.environ['SERVER_SOFTWARE'] = 'Development'
os.environ['HTTP_HOST'] = 'localhost:8080'
... do stuff ...
I run the dev server with the option "--api_port 8081" otherwise just look at the port used in the dev server logs ("Starting API server at ...").
The environ tweaks are to be able to use cloudstorage api against the dev server too.
I have this problem which I am trying to debug for a lot of time.
The setup is like this:
i. The application is a Windows application developed using VS2005, .net 2.0.
ii. I use the Cyrstal reports component Crystal Report Viewer and dynamically display various reports in the same form.
iii. The db is SQLSERVER Express 2005 and situated on a different machine.
When I run the application on the db server, I am able to view the report. However, when I run the application on a different machine which is connected to the above dbServer, I get an error. ( I dont get this error on my dev setup)
Source: CrystakReprotViewer.CS:SendDBLogonForReport() Details:Logon failed.
Details: ADO Error Code: 0x
Source: Microsoft OLE DB Provider for SQL Server
Description: [DBNETLIB][ConnectionOpen (Invalid Instance()).]Invalid connection.
SQL State: 08001
Native Error:
Error in File C:\DOCUME~1\admin\LOCALS~1\Temp\ActionPoints {52820D22-199C-4D46-A76B-70A55D9F54D5}.rpt:
Unable to connect: incorrect log on parameters. at CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.SetTableLocation(ISCRTable CurTable, ISCRTable NewTable)
at CrystalDecisions.CrystalReports.Engine.Table.set_Location(String value)
at Trivalve.UI.Client.Reports.CrystalViewer.CrystalReportViewer.SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument) in D:\Ramjee\Work\Projects\Trivalve\Trivalve\src\tfssetup\2008\Trivalve_2008\Trivalve\Reports\CrystalViewer\CrystalReportViewer.cs:line 127 rptcontrollers.dll SetTableLocation
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Thanks,
Ramjee
Use datasource=servername or ip address\instance name if available,port number
Default port number is 1433 or 1434
My problem was solved with this. Posting for the use of others.
If this is a standard installation of SQL Server Express, bear in mind that the only connection method installed by default is shared memory, and is only available on the server -- you would need to enable another connection protocol such as Named pipes or TCP/IP. To turn networking on, Use SQL Server Configuration Manager to enable relevant protocols and start SQL Browser.
It's telling you exactly what's wrong.
Details:Logon failed.
Great, we can't logon.
(Invalid Instance()).]Invalid
connection.
Okay. I bet we have "localhost" as part of the instance name in my connection string. Since I'm no longer on the "localhost", this obviously won't work. Let's try there first. Then perhaps it's the credentials that I'm using to query my database. Usually what I do is create a RO user that can only do selects on my db and use that for CR. If none of these are getting me close, let's try making sure that remote connections are enabled for SQLEXPRESS
Unable to connect: incorrect log on
parameters.
Ok it's definitely a connection issue.