Shared Data Source for Excel - sql

I am currently creating reporting within excel for lets say 'Non Advanced Users'. I Have successfully created this in and I can execute the stored procedure with parameters typed into excel cells. But when I send this to another user it is saying that it is unable to connect to the data source. Is there a way I could tell excel to use a data source on our network. The connection has SQL Authentication. Basically I want to try and avoid having to create data sources via excel on 100+ machines!!

Yes you can. You can save the connection setting in the excel file itself, and just send out that file. See picture below for step-by-step guide.
Remember to CLEAR (uncheck) the 'Always Use Connection File' in Step 6.

Related

Change database connection in pentaho without using GUI

i wanted to try to run the pentaho from Linux Centos 7.
In the server there are no GUI for it, so i can't open the Spoon GUI where we usually drag and drop the components.
If we use the Spoon, we can change the Database Connection by clicking the Database Connection then re-type the host.
But how do i do that if i can't open the Spoon? Is there a file or something where i can change those?
All transformation and job files are just XML.
You can edit a transformation in your laptop with the correct parameters, save it, find the relevant XML snippet, copy, open the ktr on the server in a text editor, delete the old db connection and paste in the new one.
It may actually be a bit tricky if you mess something up, but with a few tries you should have it done.
You can use JSON file to change database connection in Pentaho Data Integration without using GUI.
Set variable and database connection value in that variable inside that JSON file so that next time you just drag and drop JSON file in server where you cannot open Spoon GUI to change the database connection values.
Let me explain how we do it.
First create a transformation where we take JSON file as input and set that value into variable to later use that value anywhere inside that job as ${variable_name}.
JSON file looks like this ...
Browse and add your JSON file ...
Go to Fields tab and Select field ...
Now in set variable step go to Get Fields ...
Now let us suppose we have created these variables in JSON file now we use these variables to create a database connection.
${mysql_host}
${mysql_port}
${mysql_username}
${mysql_password}
${mysql_database_name}
like this ...
In this way you can build your ETL with dynamic database connection in Pentaho Data Integration. Just replace JSON file in server then database connection will be changed in that whole ETL package.
This example ETL package can be downloaded from this link:
Download

Use Excel VBA to change Powerpivot connection to csv file

How can I use vba to modify a Powerpivot connection to a csv file? I have an Excel workbook with a Powerpivot model that connects to a csv file. In the Powerpivot window, I can navigate to the Home->Existing Connections and edit the file path as desired. I can't get close to editing this in vba.
I found this link on parameterizing Powerpivot connections.
Unfortunately, I couldn't figure out how to modify to apply to csv file connection rather than database connection.
An alternate approach is described on this page. This approach creates a connection to the data in Excel itself. The connection is then available in Powerpivot. It is critical to not create the connection in Powerpivot bc the author says connections created in Powerpivot cannot be modified by vba.
I can create this connection manually through the
Data->Get External Data->From Text menu option.
I can create the same connection in vba using "Workbooks("myWorkbook.xlsm").Connections.AddFromFile "data.csv". I can manually edit this connection in the Data->Connections->Connections dialog. However, when I try to set this in vba using the WorkbookConnections.TextConnection property, vba says "Object doesn't support this property or method".
The above link focuses on database connections rather than csv file connections. However, it seems possible to set up the csv file with an
Microsoft ACE OLEDB 12.0 connection, but I can't quite grasp it.
There are similar questions on SO that address vba modifying pivot sources (like here:Changing pivot table external data source path with Excel macro).
However, I don't want to bring the data into a table in Excel, I want to connect to it so I can work with it in Powerpivot.
I could probably do this with Power Query, but since I already have the csv in the desired format, I'd rather not have to introduce this additional step.
I'm using Excel 2013 64 bit on Windows 7. Thank you for your help.
I've been playing around with something similar. Haven't succeeded yet, but maybe we can figure it out together...
One thing I've noticed is that it looks like these connections to CSV files aren't actually TextConnections like you'd expect, but rather OLEDBConnections.
EDIT: According to https://goo.gl/x17Nuj, it's just not possible:
Once you modify the connection inside PowerPivot, the link between the Excel and the PowerPivot connections is broken. In fact, you can no longer modify the connection properties in Excel and, if you want to load another table, then you have to use the PowerPivot add-in. Needing to use the add-in means that the option of modifying the connection is no longer available in VBA Because (as you have seen) there is no way to modify the PowerPivot connections using VBA.
(Emphasis is mine)
I was able to modify the file location by setting up the csv file connection as a Microsoft.ACE.OLEDB.12.0 connection. It's actually labelled "Microsoft Office 12.0 Access Database Engine OLE DB Provider" in the Data Connection Wizard. This link helped me figure it out. You need to have "Microsoft ActiveX Data Objects 6.1" added as a reference. Once the connection was created manually, here's the code I used to modify the connection:
Sub editConnection()
With ActiveWorkbook.Connections("myConnectionName").OLEDBConnection
.Connection = "OLEDB;Provider= Microsoft.ACE.OLEDB.12.0; " & _
"Data Source=\\something.com\shared\myDepartment\newDirectory; " & _
"Mode=Read;Extended Properties = ""Text;HDR=Yes;FMT=Delimited;"""
End With
ActiveWorkbook.Connections("myConnectionName").Refresh
End Sub
I didn't figure out how to modify the filename. This also forces the table name in PowerPivot to be the name of the csv file. You can't edit that without breaking the connection.

How to see Tableau Custom SQL on server without downloading workbook?

Oftentimes I need to troubleshoot a workbook that another person at my company has created and published to our server. To troubleshoot, I need to see their connection details, specifically their Custom SQL, to understand what data they are using in their extract.
Is there any way to view this connection info (specifically their SQL code) when viewing the published workbook on the server (web) version?
I am an admin and I am able to download their workbook to my desktop version of tableau, then open it, then reconnect to the data, then look through the data connections they created, to see their SQL. But it's a really cumbersome process.
All I'm looking to do is, when looking at a published workbook, see the data connection details so that I can see the Custom SQL, without going through the process of downloading I described above.
You can get some details on the SQL statement by creating a performance recording.
From the Tableau Server Admin Guide:
Enable Performance Recordings:
Choose the Admin button in Tableau Server.
Choose Site.
Select a site.
Choose Edit.
In the Edit Site dialog box, select Allow Performance Recording.
Choose OK.
You start performance recording for a specific view by adding ?:record_performance=yes to
the url. For example:
http://server.site.com/views/Variety/BaseballStatistics?:record_performance=yes
Now, notice a new link at the top of your view called "Show Performance Recording".
Click this to open the generated performance workbook dashboard. Click on the bar chart and observe the SQL appear at the bottom of the view. Note, the SQL text will truncate after about 250 characters.
The admin guide suggests viewing the "Tableau Log" to find the full SQL statement.. I have looked at all the server side logs in C:\ProgramData\Tableau\Tableau Server\data\tabsvc\logs but cannot locate the SQL. (please reply if you know where to find this?)
You can also run a database trace to see the SQL that the database sees. For example, for MS SQL Server, run the Profiler tool, setup a default trace, and filter on "Application Name" = "Tableau Protocol Server 8.0" or similar.
I have version 8.1 and this is how I got around this problem. Tableau shows a 'Custom SQL Warning' when you open a workbook that contains the custom SQL. You can copy all the text in this message by simply Ctrl + C as this is any other Windows warning message. And then paste it your editor of choice to analyze it.
I do not know if this works on earlier versions.
I thought you could do this easily, and originally answered that you could, but I didn't pay close attention to your question. You can change some things about data connections without editing the workbook, including the ip address or name of the database server, but there doesn't appear to be a simple way to access custom sql without downloading the workbook.
Go to the Administrator page and select Data Connections.
You can enter some search criteria to filter the list of data connections shown (or not).
Find the workbook in question by scanning the second column -- you can sort the column if that helps.
Then select the corresponding data connection in the 4th column to see the details of the connection.
If it makes sense for the connection, you can also modify the connection directly at the server. This is really useful if you, say, need to move your enterprise database to a new IP address or change a database password, without downloading, modifying and republishing alot of workbooks.
An even better practice is to start using shared data connections hosted on Tableau server instead of having each workbook have its own local copy of connection and related info.

How to extract data from a database and populate a sheet in Excel

I am storing data in a backend database (PostgreSQL) which is running on a Linux machine. I want to be able to fetch data from the database, and populate a sheet in an excel workbook, so that I can carry out analysis in Excel.
It has been quite a while since I wrote anything in VBA, so I would appreciate some help (or links) in getting started. I would like to know the best way to approach this:
Pure VBA solution OR
Mixture of C# or other .Net language for data extraction logic and VBA for manipulating Excel objects (sheet data population etc)
Any ideas, tips, snippets and/or links that can help me get started on the twin objectives:
fetching data from a backend database (PostgreSQL) into Excel
populating a specified sheet in Excel with the columnar data retreived from the database
will be much appreciated.
If you are just trying to import data, Excel can do that without additional code. Just set up your windows client to connect to your postgreSQL server thru ODBC. (Here's one way guide to setting that part up: enter link description here
Then in Excel (Use a modern version, like 2007 or greater) from the "Data" tab, click on "Existing Connections" to connect to the ODBC connection you set up and pick the tables/data to import into excel. Once the spreadsheet has loaded the data, you can just click the "Refresh All" button to update the data.

Writing data back to SQL from Excel sheet

I know it is possible to get data from a SQL database into an excel sheet, but i'm looking for a way to make it possible to edit the data in excel, and after editing, writing it back to the SQL database.
It appears this is not a function in excel, and google didn't come up with much usefull.
If you want to have the Excel file do all of the work (retrieve from DB; manipulate; update DB) then you could look at ActiveX Data Objects (ADO). You can get an overview at:
http://msdn.microsoft.com/en-us/library/ms680928(VS.85).aspx
You want the Import/Export wizard in SQL Management Studio. Depending on which version of SQL Server you are using, open SSMS (connect to the SQL instance you desire), right click on the database you want to import into and select Tasks.. "Import Data".
In the wizard, click Next (past the intro screen) and from the Data Source drop list select "Microsoft Excel". You specify the path and file name of the Excel spreadsheet, whether you have column headings or not.. then press Next. Just follow the wizard through, it'll set up the destination (can be SQL Server or another destination) etc.
There is help available for this process in SQL Server Books Online and more (a walkthrough) from MSDN.
If you need something deployable/more robust (or less wizard driven) then you'd need to take a look at SQL Server Integration Services (for a more "Enterprise" and security conscious approach). It's probably overkill for what you want to accomplish though.
There is a new Excel plug-in named "MySQL for Excel" : http://www.mysql.com/why-mysql/windows/
I just had a need to do this, and this thread has been quiet for a long time, so I thought it might be useful to supply a recent data point.
In my application roving salespeople use a copy of an Excel workbook that tracks the progress of a prospect through a loan application. The current stage of the application needs to be automatically saved back to a remote SQL database so that we can run reporting on it.
Rejected methods for updating the database from Excel:
SSIS and OpenRowSet are both methods for allowing SQL Server to pull the data from Excel, and don't work very well when the Excel workbook is sitting in an undefined location on a user's computer, and certainly not when the workbook is currently open in Excel.
ADO is now, if not actually deprecated, nevertheless looking very long in the tooth. Also, I wanted the solution to be robust in the face of the user possibly not being connected to the internet.
I also considered running a web API on the destination server. Macros in the Excel workbook connect to the web API to transfer data. However, it can sometimes be painful to allow a web API to talk to the outside world. Also, the code to make it robust in the face of temporary loss of internet connection is painful.
The adopted solution:
The solution I plan to adopt is low-tech: email. Excel emails the data to an address hosted on an Exchange server. Everyone in the company has Outlook installed, so the emails are sent by programmatically adding them to the Outlook Outbox. Outlook nicely handles the case when the user is offline. At the server end, a custom C# executable, fired up at regular intervals by the Task Scheduler, polls the inbox and processes the emails.
You could use try these add-ins :
www.QueryCell.com (I created this one)
www.SQLDrill.com
www.Excel-DB.net
You can use the OPENROWSET function to manipulate Excel data from a T-SQL script. Example usage would be:
UPDATE OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;DATABASE=c:\MySpreadsheet.xls',
'Select * from MyTable')
SET Field1='Value1' WHERE Field2 = 'Value2'