Click here to Skip to main content
15,912,457 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my project, I am trying to use a online database which is hosted on my web server, and I want for users to be able to perform queries from their clients on my database.

Is there a way for me to allow them to issue and execute queries without having them download the entire database every time?

What I have tried:

Here is what I am working with: (C#)
C#
namespace Test
{
    class Program
    {
        public static SQLiteConnection m_dbConnection;

        static void Main(string[] args)
        {
            m_dbConnection = new SQLiteConnection(@"Data Source=https://dl.mydomain.com/Urls.sqlite");
            m_dbConnection.Open();
            test();
        }

        private static void test()
        {
            String query = "SELECT * FROM table";
            SQLiteCommand prepQuery = new SQLiteCommand(query, m_dbConnection);
            SQLiteDataReader reader = prepQuery.ExecuteReader();

            Console.WriteLine(reader["testcolumn"].ToString());
        }
    }
}
Posted
Updated 10-Mar-16 11:54am
Comments
Maciej Los 10-Mar-16 17:51pm    
Forget about SQLite. Use MySQL, PostgreSQL or any other free database server based engine. File based databases may fast get corrupted in LAN/WAN environment. SQLite is very good as one-in-time connection in local machine only.

No, you can't. The clients cannot use a file-based database over HTTP.

Using SqlLite on the server, your only solution is to create a Web Service or WebApi the clients can call to do the database operations for the them.
 
Share this answer
 
Comments
Maciej Los 10-Mar-16 18:03pm    
Short and to the point! +5!
Member 12383988 10-Mar-16 18:06pm    
Alright. Thanks!
I'd suggest to read SQLite documentation[^], which says exactly the same as i mentioned in the comment to the question.

Quote:

Server-side database

Systems designers report success using SQLite as a data store on server applications running in the datacenter, or in other words, using SQLite as the underlying storage engine for an application-specific database server.

With this pattern, the overall system is still client/server: clients send requests to the server and get back replies over the network. But instead of sending generic SQL and getting back raw table content, the client requests and server responses are high-level and application-specific. The server translates requests into multiple SQL queries, gathers the results, does post-processing, filtering, and analysis, then constructs a high-level reply containing only the essential information.

Developers report that SQLite is often faster than a client/server SQL database engine in this scenario. Database requests are serialized by the server, so concurrency is not an issue. Concurrency is also improved by "database sharding": using separate database files for different subdomains. For example, the server might have a separate SQLite database for each user, so that the server can handle hundreds or thousands of simultaneous connections, but each SQLite database is only used by one connection.

...

Situations Where A Client/Server RDBMS May Work Better

Client/Server Applications

If there are many client programs sending SQL to the same database over a network, then use a client/server database engine instead of SQLite. SQLite will work over a network filesystem, but because of the latency associated with most network filesystems, performance will not be great. Also, file locking logic is buggy many network filesystem implementations (on both Unix and Windows). If file locking does not work correctly, two or more clients might try to modify the same part of the same database at the same time, resulting in corruption. Because this problem results from bugs in the underlying filesystem implementation, there is nothing SQLite can do to prevent it.
 
Share this answer
 
v3
Comments
Member 12383988 10-Mar-16 18:06pm    
Alright. Thanks!
Maciej Los 11-Mar-16 1:55am    
You're very welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900