Encrypt the SQL query - sqlite

In my C++ program, I will invoke SQLite to execute SQL queries. But these queries are just stored as normal string constants in C++ so it is easy to be decoded via reverse engineering method. Does SQLite provide a good way to encrypt the SQL query strings while does not affect the performance when executing the queries?
Thanks

Related

Changing the database from SQL Server to PostgreSQL in creating ASP.NET web application?

I am currently using SQL Server for database and Dapper (ORM) for mapping relation to model classes. I have used multiple reads in Dapper so I am able to get multiple tables at one call to the database. But due to a certain circumstance, I have to change my database connection from SQL Server to PostgreSQL. In Postgresql, there are no options facilities for using the power of query multiple reads.
Is there any way to handle the below situation in Postgresql?
using (var multi = conn.QueryMultiple(query, param, commandType: CommandType.StoredProcedure))
{
obj.InventoryItemOrder = multi.Read<InventoryItemOrder>()
.FirstOrDefault(); //getting single object data (so firstordefault)
obj.InventoryItemDataModel = multi.Read<InventoryItemDataModel>(); //list
}
Can I use this concept when dealing with PostgreSQL and Dapper in building an ASP.NET application?
I'm not familiar with Dapper, but from a quick look at the doc, it appears that QueryMutiple basically runs multiple statements in the same command (that is, separated by a semicolon) and then maps the results of each statement.
You can certainly do the first part of that with Postgres: combine multiple statements into one separated by a semicolon. They will both be run. However, I am not aware of anything within Postgres itself that will automatically return results of the statements separately. Depending on exactly how you are interfacing with Postgres and getting the results, you could perhaps create a custom method of mapping these results.
From a purely database perspective, you don't gain much, if any, performance advantage from the behavior described in QueryMultiple as long as you issue the separate queries on the same connection.
It's the connection startup and teardown that is expensive, and even Dapper would have to issue and map the results for each query, so there is no performance benefit there. Rather, it's essentially a matter of syntactic sugar.
It's not clear from a quick look at the doc if Dapper is compatible with Postgres. If it is, and its QueryMultiple call is supported there, then it's probably handling the mapping of the multiple statements within the ORM itself.
If Dapper does not support Postgres, however, I would recommend simply issuing the queries separately and handling their results separately.

Realm Java - Using raw sql

I was searching the forum for a way to use a raw query in the realm database, but the examples in the forum doesn't exist or don't work.
Can anyone explain me how can I use a raw sql query on a Realm database?
Thanks for the help
Realm is not based on SQLite. It is an Object Store or Graph database. This means that SQL queries doesn't really make sense, since e.g JOIN's doesn't exist at all. So no, that isn't possible. All queries are created using realm.where() and similar methods.

Best UI interface/Language to query MarkLogic Data

We will be moving from Oracle and use MarkLogic 8 as our datastore and will be using MarkLogic's Java api to talk with data.
I am exploring for any UI tool (like SQL Developer is there for Oracle), which can be used for ML. I found that ML's Query Manager can used for accessing data. But I see multiple options wrt language:
SQL
SPARQL
XQuery
JavaScript
We need to perform CRUD operations and search for data, and our testing team is aware of SQL (for Oracle), so I am confused which route I should follow and on what basis I should decide which one/two will be better to explore. We are most likely to use JSON document type.
Any help/suggestions would be helpful.
You already mention you will be using the MarkLogic Java Client API, that should provide most of the common needs you could have, including search, CRUD, facets, lexicon values, and also custom extension though REST extensions as the Client API will be leveraging the MarkLogic REST API. It saves you from having to code inside MarkLogic to a large extent.
Apart from that you can run ad hoc commands from the Query Console, using one of the above mentioned languages. SQL will require the presence of a so-called SQL view (see also your earlier question Using SQL in Query Manager in MarkLogic). SPARQL will require enabling the triple index, and ingestion of RDF data.
That leaves XQuery and JavaScript, that have pretty much identical expression power, and performance. If you are unfamiliar with XQuery and XML languages in general, JavaScript might be more appealing.
HTH!

Convert function Postgresql to Sqlite

I have a problem with my iPad app. I have to convert a PostgreSQL database to SQLite database. Luckily I did it but I didn't know how to convert the PostgreSQL functions. Anyone knows how to did it? Or how can I get the same result in Sqlite?
Thanks in advance, Luca
As you allready discovered sqlite has no functions. So you will probably have to move some logic from the function and the single query out of your db into your app. This will probably mean executing a query looking at the result and based on that executing some more queries. So you can do the logic of the function in your app.
While this is not recommended in PostgreSQL as performance suffers from many small queries the performance loss in SQlite is much smaller as it is an embedded database (no communication overhead) and it's planner is more straight forward which makes the planning overhead of seperate queries smaller.

Does SQLite support stored procedures?

I am evaluating the SQLite database for my requirement. Does SQLite support stored procedures?
If yes then what are the limitations? Does SQLite support the range?
No, it does not. See Appropriate Uses For SQLite on the main site.
A key reason for having stored procs in a database is that you're executing SP code in the same process as the SQL engine. This makes sense for database engines designed to work as a network connected service but the imperative for SQLite is much less. Given that it run as a DLL in your current process it makes more sense to implement SP in the client language.
You can however extend SQLite with your own user defined functions in the host language (PHP, Python, Perl, C#, Javascript, Ruby etc). I've done this in C# using DevArt's SQLite to implement password hashing.
If you really want to store SQL code in the DB (such as when you want to develop cross-platform apps), you can create a specific table that will store raw SQL commands that do the thing, then in the client you obtain the SQL command. e.g.
var myString = db.CreateCommand("SELECT SqlColumn FROM tablewithsqlcommands WHERE Procname=theprocedureIwant").ExecuteScalar();
and then execute it in the second step
var myResult = db.CreateCommand(myString).whatever_execution_method_you_need();

Resources