Have created a Laravel schema and the column has enum data type. By default, it should save Agent in the column which works fine. When a user inserts some data am trying to change it to Agency but when checking on the DB it still remains as Agent:
Kindly assist?
Database schema
$table->enum('agent_or_agency', array('Agent','Agency'))->default('Agent');
Saving data in the above column from the logic
$data = new Agents();
$data->agent_or_agency = 'Agency';
$data->save();
I am trying to create a postgresql database named my_database which will have table_yesterday, table_today, and table_tomorrow. I have never created a database before because I have only worked with .csv files.
The goal is to write a program that updates a few database tables that will be used by other programs, and if that database doesn't exist then create it and then download a ton of data into it.
How would I create a database with the username and password in my config.py file using python?
All the code I can find gives examples in sqlite.
I am using Azure Machine Learning to clustering data.
The input data is from an Azure SQL Database, and it works fine.
At the end of everything I want to write the output to a table in the same Azure SQL Database, but I get this error:
Error: Error 1000: AFx Library library exception:
Sql encountered an error: Login failed for user
Anyone any idea?
Thank you very much!
Please follow the instructions and examine the examples provided here to properly use the Export Data module to save the data of ML to Azure SQL Database.
How to Export Data to an Azure SQL Database
Add the Export Data module to your experiment. You can find this module in the Data Input and Output group in the experiment items list in Azure Machine Learning Studio.
Connect it to the module that produces the data that you want to export to Azure SQL DB.
For Data destination, select Azure SQL Database. This option supports Azure SQL Data Warehouse as well.
Set the following options specific to Azure SQL Database or Azure SQL Data Warehouse.
Database server name
Type the server name that is generated by Azure. Typically it has the form <generated_identifier>.database.windows.net.
Database name
Type the name of a database on the server you just specified.The database must already exist; the Export Data cannot create it.
Server user account name
Type the user name of an account that has access permissions for the database.
Server user account password
Provide the password for the specified user account.
Comma-separated list of columns to be saved
Type the names of the columns in the experiment that you want to write to the database.
Data table name
Type the name of the table where data will be stored.
For Azure SQL Database, if the table does not exist, it will be created. For Azure SQL Data Warehouse, the table must already exist and have the correct schema, so be sure to create it in advance.
Comma-separated list of datatable columns
Type the names of the columns as you wish them to appear in the destination table. The columns should correspond in order with the column names that you list in Comma-separated list of columns to be saved.
if you are writing to Azure SQL Data Warehouse, the columns names must match those already in the destination table schema.
Number of rows written per SQL Azure operation
Indicate how many rows should be written to the destination table in each batch. By default, the value is set to 50, which is the default batch size for Azure SQL Database. However, you should increase this value if you have a large number of rows to write.
TIP:
For Azure SQL Data Warehouse, we recommend that you set this value to 1. If you use a larger batch size, the size of the command string that is sent to Azure SQL Data Warehouse can exceed the allowed string length, causing an error.
If you don't want to write new results each time you run the experiment, select the Use cached results option. If there are no other changes to module parameters, the experiment will write the data the first time the module is run, and thereafter not perform writes.
However, a write will always be performed if any parameters have been changed in Export Data that would change the results.
Run the experiment.
Find the issue!
I needed to create an specific user with this SQL code:
CREATE USER AMLApplicationUser WITH PASSWORD = '************';
and then add the user to these roles on the database I want to write.
ALTER ROLE db_datareader ADD MEMBER AMLApplicationUser;
ALTER ROLE db_datawriter ADD MEMBER AMLApplicationUser;
I guess only the datawriter role is enough, but I needed datareader too.
So in conclusion, seems that database admin role can be used to read data, but not to write data from AML.
Thank you for your help!
My job has tools that require us to mass upload data through Excel workbooks, so I'm trying to embed my SQL results into my files to save me a step. I've created the data connection, but haven't quite figured out the code format in the 'Definition' box yet.
Right now I have:
select custcontnum from "CONTACT"."dbo"."Incont" where custcode='SNH' and username = '[Custcontnums$G2]'
But it's pulling back blank. (If I define the username criteria itself between single quotes, it does work) Eventually I would like to create an "in" statement for the username criteria, so something like:
select custcontnum from "CONTACT"."dbo"."Incont" where custcode='SNH' and username in ('[Custcontnums$G2]','[Custcontnums$G3]','[Custcontnums$G4]')
What is the correct format for an excel reference in the data connection feature for Excel?
I have an application that uses database. Data about how to connect to the database is stored in a properties file. There you can find server name, database name, username, password, ... I read this file and make a connecton to a database in my program.
How can I "hide" the password, so that someone else would have it hard time to retrieve that password?