Re: [sqlalchemy] Build With Different Backends [RESOLVED]

2015-05-19 Thread Rich Shepard

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tue, 19 May 2015, Mike Bayer wrote:


Examples: date and time functions are entirely different on both
platforms, schema migration operations e.g. ALTER are generally not
supported on SQLite, SQLite has very different behavior regarding foreign
key constraints (in that they do nothing unless special directives are
emitted per-connection), ...


Mike,

  I wondered about this. It's a scientific application with many date and
time columns in tables and relies on foreign keys extensively to associate
rows in a details table with a specific row in a header table.

A good amount of starting detail is available in the documentation for both 
backends:

http://docs.sqlalchemy.org/en/rel_1_0/dialects/sqlite.html
http://docs.sqlalchemy.org/en/rel_1_0/dialects/postgresql.html


  Because I'm starting to learn sqlalchemy I'll begin with the sqlite3
version. I should be able to have sqlalchemy generate the tables from the
declarative base .py file so I don't need to create it in advance with
sqlite. The docs mentions that the sqlite version built into python is used.
I presume that I can specify a newer version that's available since the
resultin .db will be packaged with the rest of the application.

Thanks very much,

Rich
-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iD8DBQFVW8ypugEIjC001L0RAuPFAJ9ZbhU6S7p5QLsDeQKnJ7mSWr61QACglHhB
XnZZ2otJI7RhxbDohcWPnyM=
=/nLQ
-END PGP SIGNATURE-


Re: [sqlalchemy] Build With Different Backends

2015-05-19 Thread Mike Bayer



On 5/19/15 1:51 PM, Rich Shepard wrote:
  I thought there was a thread on this but I cannot find it so please 
point

me to that thread if it exists.

  An application will be provided in two versions: a single-user version
with SQLite3 as the backend, and a multi-user version with PostgreSQL 
as the

backend.

  Am I correct that the only necessary change in the SQLAlchemy code 
is the

engine specification?
There's not a simple yes or no answer to that question.  Yes, if you 
change the engine specification, a simple SQLAlchemy application and 
even a very complex one will successfully interact with SQLite and 
Postgresql with no other changes.   This is very common.


But also, no, in that if your application relies upon special, or even 
not-so-special features of SQLite or Postgresql and provides no 
equivalent operation for the other, the use of these features would have 
to be developed such that an equivalent operation is performed on each 
backend.  Examples: date and time functions are entirely different on 
both platforms, schema migration operations e.g. ALTER are generally not 
supported on SQLite,  SQLite has very different behavior regarding 
foreign key constraints (in that they do nothing unless special 
directives are emitted per-connection), transactional features like 
SAVEPOINT have caveats on SQLite, Postgresql has a vast array of 
datatypes like HSTORE, JSON that are not supported on SQLite, SQLite has 
a very restrictive concurrency model compared to Postgresql and pretty 
much any other database, SQLite does not support RETURNING, does not 
support right-nested JOINs, etc. etc. etc., there are literally many 
hundreds of behavioral and feature differences.


However, it's very possible that your application is not making use of 
any of these features or behaviors, or is making adequate use of 
SQLAlchemy Core/ORM such that a subset of these differences are 
abstracted away; examples: RETURNING for primary key retrieval is used 
internally only if available, right-nested joins are abstracted away in 
many ORM scenarios, platform-agnostic datatypes like Boolean and 
DateTime provide emulation for these non-existent types on SQLite.


The only way to know is via research of backend capabilities and 
thorough testing.   SQLAlchemy's job is just to expedite the 
communication with these backends and provide a modicum of commonality 
between them, but it does not limit all operations to the lowest common 
denominator of database features; such a system would be largely 
unusable especially given SQLite's extremely limited capabilities.


A good amount of starting detail is available in the documentation for 
both backends:


http://docs.sqlalchemy.org/en/rel_1_0/dialects/sqlite.html

http://docs.sqlalchemy.org/en/rel_1_0/dialects/postgresql.html







--
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Build With Different Backends

2015-05-19 Thread Rich Shepard

  I thought there was a thread on this but I cannot find it so please point
me to that thread if it exists.

  An application will be provided in two versions: a single-user version
with SQLite3 as the backend, and a multi-user version with PostgreSQL as the
backend.

  Am I correct that the only necessary change in the SQLAlchemy code is the
engine specification?

Rich