I can connect to mysql ok.
i want to get the full raw data
of the query.
in python i think all data is stored in
rows[0]
i am not certain how it is in node.js
i want to print the full mysql output
i want to assign it to the variable "bb"
connection.connect();
var queryString = 'SELECT * FROM 1_accounts';
connection.query(queryString, function(err,rows,fields){
bb = rows[0].toString();
});
connection.end();
If you want to see a text representation of rows use JSON.stringify(rows) instead of rows.toString()
Related
i have a question. how to create one input text and fill it with this format:
, then save the result to database with separated fields:
- name
- age
- address
like example input : "Rangga Lawe 22 Jl Soekarno Jakarta"
so, it will save to database as follows:
- “Rangga Lawe“ to name field
- “22” to age field
- “Jl Soekarno Jakarta” to address field
please help me, thankyou.
im using mongoDb as my database and use node.js framework
Try splitting the value on the basis of some parameters. like instruct the user to input comma separated values. OR
You have to make input field fixed length for each of your values..
if you only have one input means that you have only one string that you want to parse into an array and then insert this fields into your database.
like this:
var str = "Rangga Lawe 22 Jl Soekarno Jakarta";
var result = str.split(" ");
//now you can work with the array
//console.log(result[0]) will contain "Rangga"
You can split the one input into multiple ones at the Schema level if you use Mongoose ORM for your mongoDB database using the .pre middleware.
Here is an example :
UserSchema.pre('save', function(next) {
const user = this
const data = user.fieldYouWantToSplit.split(" ")
user.address = data[0]
user.number = data[1]
return next()
})
})
This question already has an answer here:
Firebase query - Find item with child that contains string
(1 answer)
Closed 4 years ago.
In firebase, how can one go about running a query to find matches which have a specific word in the string?
for example querying all descriptions that have the word happy in them.
I am able to do this with JS but that means I have to load the entire DB which is over 300 items...
Cheers!
You don't have to download the entire DB for this (i assume you'r using realtime database over firestore).
You can filter your data mixing orderByChild() or orderByKey() or orderByValue() with query methods like startAt(), endAt() and equalTo().
For example, if your list of nodes url is
https://mydb-xxxx.firebaseio.com/parentnode/childnodeslist
You can query in this way:
// Find all nodes whose property myString is "hello"
var ref = firebase.database().ref("parentnode/childnodeslist");
ref.orderByChild("myString").equalTo('hello').once(‘value’).then(function(element){
console.log(element);
});
see the query doc and how to structure your data in firebase
EDIT: BASED ON COMMENTS:
If you want to make a full text search you can:
1) Make it client side
// assume "myString" is your param name
var word = 'hello';
var listOfItems = [];
firebase.database().ref("parentnode/childnodeslist").then(function(list){
listOfItems = list.map(function(item){
if( item.myString.indexOf(word) >= 0){
return {id: item.id, word: item.myString}
}
})
})
2) Use a third party tools like ElasticSearch (as suggested by #Frank-van-Puffelen) or Algolia
3) Use Cloud Functions
I'm wondering if there's a way to get "raw" results from a OrmLite query in ServiceStack.
I'll explain... I know I can use:
var results = Db.SqlList<MyModel>("SELECT * FROM TableName");
passing the model of my output results, but if I don't know it?
Can I get "raw" results without know the types of the data I'm reading?
Thank you
Have a look at the support of Dynamic Result sets in OrmLite.
Where you can access an un-typed schema with a List<object>, e.g:
var results = Db.SqlList<List<object>>("SELECT * FROM TableName");
Or if you want the column names as well you can use:
var results = db.Select<Dictionary<string,object>>("SELECT * ...");
OrmLite also has a version of Dapper embedded if you prefer to access the results using dynamic instead, e.g:
IEnumerable<dynamic> results = db.Query("SELECT * FROM TableName");
I'm trying to make a table of values inside hubot and he pass it's values to redis-brain.coffee but i just know a way: robot.brain.get("blablabla").
This will get a string from redis-brain and i need some kind of table.
How I'll use it:
At first call of this function, hubot will load the full database to the memory, then, if there's
robot.catchAll (msg) ->
if not quiet
text = msg.message.text
ector.setUser msg.message.user.name
if not loaded_brain
ector_brain = robot.brain.get('ector_brain') #need to be some type of table - In mysql should be like a select
ector.addEntry ector_brain
loaded_brain = true
else
ector.addEntry text
ector_brain = ector_brain+text #this line should insert the value of text inside ector_brain table. -- In mysql shoud be like an insert into
ector.linkNodesToLastSentence previousResponseNodes
response = ector.generateResponse()
previousResponseNodes = response.nodes
msg.reply response.sentence
So, how do I create a table in redis from hubot?
robot.brain.get and robot.brain.set operates with JSON objects, not only strings. Just place an object with your data structure of choice in the brain and get it back when necessary.
I am new to C# and was experimenting a bit trying to insert stuff into a SQL Server CE database. I don't understand why this code is not working. I am getting a
System.Data.SqlServerCE.SqlCeException
error pointing to the com1.ExecuteNonQuery(); line when the program is run.
I am attaching my code that i am using to insert into the table.
//Connecting to SQL Server
SqlCeConnection conn1 = new SqlCeConnection();
conn1.ConnectionString = connection; //connection is a string variable which has the connection details
conn1.Open();
SqlCeCommand com1 = new SqlCeCommand();
com1.Connection = conn1;
com1.CommandType = CommandType.Text;
com1.CommandText = "INSERT into data(pname, budget, dcommision, advance, phone, cdetails, mail) values(#pname , #budget, #dcommision, #advance, #phone, #cdetails, #mail)";
com1.Parameters.AddWithValue("#pname", textBox8.Text.Trim());
com1.Parameters.AddWithValue("#budget", budget);
com1.Parameters.AddWithValue("#dcommision", textBox7.Text.Trim());
com1.Parameters.AddWithValue("#advance", advance);
com1.Parameters.AddWithValue("#phone", phone);
com1.Parameters.AddWithValue("#cdetails", richTextBox1.Text.Trim());
com1.Parameters.AddWithValue("#mail", textBox3.Text.Trim());
com1.ExecuteNonQuery(); //Executing the SQL query
com1.Dispose(); //Closing SQL Server connection
conn1.Close();
Is something wrong with my query? I am really a newbie so some help would be really appreciated. Thanks
Your table data have also column cname which you don't include in INSERT list, and column i marked as NOT NULL. Include the column too into INSERT list or provide DEFAULT value for this column in DB.