473,725 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to support SQLite and PostgreSQL at the same time?

Hi everyone!

One quick question, with hope that the answers will be the same :). What
to use if I want to ship two versions of my application, one using SQLite,
small embedded database for single-computer instalations, and one using
PostgreSQL for multi-computer instalations.

Of course, my goal is to make as little as possible changes in the code to
support both DB engines, especially as the application grows. So if you
could point out few hints to Google about, I would be most gratefull.

Thanks in advance...

--
_______ Karlo Lozovina - Mosor
| | |.-----.-----. web: http://www.mosor.net || ICQ#: 10667163
| || _ | _ | Parce mihi domine quia Dalmata sum.
|__|_|__||_____ |_____|
Dec 13 '05 #1
2 1482
Karlo,

Typically, this would require you to use the base class/interfaces that
are common to the data providers. This means using IDbConnection,
IDbCommand, etc, etc, (or, in .NET 2.0, all data classes should inherit from
the new base classes, DbConnection, DbCommand, etc, etc) instead of the
database-specific classes.

This also means that you will have to account for different flavors of
SQL (or rather, different query languages altogether). If you are not doing
anything horribly complex with SQL that requires platform specific commands,
then you can get away with using SQL embedded/generated in your code (if
that is your preference). However, the better way to do this is to abstract
out the database functionality into stored procedures, which require a name,
and a parameter list. You just have to make sure the name and parameter
list are the same between the two database implementations . Then, calling
your stored proc using the same code should be a breeze.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Karlo Lozovina" <_karlo_@_mosor .net_> wrote in message
news:Xn******** *************** ******@161.53.2 .66...
Hi everyone!

One quick question, with hope that the answers will be the same :). What
to use if I want to ship two versions of my application, one using SQLite,
small embedded database for single-computer instalations, and one using
PostgreSQL for multi-computer instalations.

Of course, my goal is to make as little as possible changes in the code to
support both DB engines, especially as the application grows. So if you
could point out few hints to Google about, I would be most gratefull.

Thanks in advance...

--
_______ Karlo Lozovina - Mosor
| | |.-----.-----. web: http://www.mosor.net || ICQ#: 10667163
| || _ | _ | Parce mihi domine quia Dalmata sum.
|__|_|__||_____ |_____|

Dec 13 '05 #2
Karlo,
As a follow - up to Nicholas' post, if you use the provider model with
interfaces as he described, the only other caution is that you will need to
consider textual SQL statements rather than stored procedures, as SQLite does
not support stored procs.

If you can use .NET 2.0, Robert Simpson has done a remarkable job with his
SQLite ADO.NET provider for .NET 2.0 here:

http://sqlite.phxsoftware.com/

Unfortunately, I am not aware if there is yet a PostGres provider for the
2.0 framework.
--Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Karlo Lozovina" wrote:
Hi everyone!

One quick question, with hope that the answers will be the same :). What
to use if I want to ship two versions of my application, one using SQLite,
small embedded database for single-computer instalations, and one using
PostgreSQL for multi-computer instalations.

Of course, my goal is to make as little as possible changes in the code to
support both DB engines, especially as the application grows. So if you
could point out few hints to Google about, I would be most gratefull.

Thanks in advance...

--
_______ Karlo Lozovina - Mosor
| | |.-----.-----. web: http://www.mosor.net || ICQ#: 10667163
| || _ | _ | Parce mihi domine quia Dalmata sum.
|__|_|__||_____ |_____|

Dec 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2106
by: Robert Fitzpatrick | last post by:
I am getting the following problem with trying to install from source PHP 4.3.6 with PG support on FreeBSD 5.2.1. I have PostgreSQL 7.4.2 recently upgraded from 7.3.x and it is up and running fine. I also have Heimdal 0.6 installed and PostgreSQL was built with that support. Is the error below from something missing on the Heimdal side of things or PostgreSQL? And what does anyone suggest to resolve the issue? Maybe I need to rebuild...
1
1204
by: DurumDara | last post by:
Hi ! I want to process many data with python, and want to store in database. In the prior version of my code I create a simple thing that delete the old results, recreate the database and fill up it. But that is not too flexible, because when an power supply or hardware problem occured, all of the processed items are lost. Then I thinking about a solution that can continue the work. This is
1
2578
by: David Fowler | last post by:
I'm new to getting in touch with other PHP users/PHP team, so please excuse me if this post is at all inappropriate or in the wrong place. In the current release of PHP (5.1.4) and in the CVS for PHP5.1.* and 5.2.* the SQLite source version only stands at 3.2.8, while the actual realease is now at 3.3.6. What I was wondering is whether or not this could be updated, as there have been numerous bug fixes in the SQLite source in the past 6...
8
1176
by: John Salerno | last post by:
I was just thinking, since Python 3.0 is supposed to clean up a lot of the unnecessary or redundant features of Python and make other things more streamlined, does it seem to anyone that including SQLite goes against this goal? This is just me thinking out loud, mind you, but it seems like including a database module (especially one that many people won't use in favor of MySQL or PostgreSQL, etc.) is weighing down the standard library. I...
9
1244
by: Prateek | last post by:
I have a bit of a specialized request. I'm reading a table of strings (specifically fixed length 36 char uuids generated via uuid.uuid4() in the standard library) from a file and creating a set out of it. Then my program is free to make whatever modifications to this set. When I go back to save this set, I'd like to be able to only save the new items. Currently I am creating a copy of the set as soon as I load it and then when I go...
20
5390
by: Rob Stevens | last post by:
Can someone tell me how to import the sqlite3.dll file into c#. I am pretty new to this, and I want to use sqlite. The problem is I don't have a clue on how to import the dll file so i can call the references to it. Thanks
8
3414
by: Gilles Ganault | last post by:
Hello I need to compile PHP5 with SQLite statically and without PDO. I don't need DB-independence, so it's fine using sqlite_*() functions instead of PDO. 1. I've downloaded, compiled, and installed sqlite.org/sqlite-3.5.4.tar.gz, and... 2. used "--with-sqlite --disable-pdo", but it fails.
3
275
by: Daniel Fetchinson | last post by:
Does Python 2.5.2's embedded SQLite support full text searching? Sqlite itself is not distributed with python. Only a python db api compliant wrapper is part of the python stdlib and as such it is completely independent of the sqlite build. In other words, if your sqlite build supports full text searching you can use it through the python sqlite wrapper (that is part of the stdlib) and if it doesn't then not. This is true for any sqlite...
0
2571
by: Joe Goldthwaite | last post by:
Thanks Guilherme. That helped. I guess I was thinking that pysqlite would automatically come with some version of sqlite. The fact that it doesn't is what was causing me to get the strange results. I downloaded the Windows version of the SQLite3.dll. I didn't know where to put it so I first put it in its own directory and tried to register it. That didn't work so I just moved it to the pysqlite directory in site-packages. That did...
0
8886
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9255
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9168
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6701
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6010
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4780
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2154
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.