Diez B. Roggisch wrote: > > Thanks, Steve and Diez, for the replies. I didn't think it was > > possible, but it was worth asking :-) > > > > I will try to explain my experience with popen() briefly. > > > > I have some sql scripts to create tables, indexes, procedures, etc. At > > present there are about 50 scripts, but this number will grow. I have > > been running them manually so far. Now I want to automate the process. > > > > I am supporting PostgreSQL and MS SQL Server, and the syntax is > > slightly different in some cases. Rather than maintain two sets of > > scripts, I prefix some lines with -pg- or -ms- to indicate the > > platform, and then use Python to parse the scripts and generate a > > correct output for each platform, passing it to 'psql' and 'osql' > > respectively, using popen(). > > Why don't youn use te python DB-Api instead? > > > Regards, > > Diez
My scripts are used to create the tables in the database. I didn't think that DB-API covered that. However, even if it did, I don't think it would handle differences such as the following. For Unicode support, PostgreSQL uses the character-set specified when the database is created. SQL Server allows you to specify it for each column, using the datatype NCHAR and NVARCHAR instead of CHAR and VARCHAR. PostgreSQL uses data types called DATE and TIMESTAMP. SQL Server uses DATETIME (it also uses TIMESTAMP, but that is used for something else). Both DBMS's have the concept of a column which is automatically assigned a 'next number' each time a row is created, but the syntax for defining the column is completely different. PostgreSQL allows the use of a WHERE clause when creating an INDEX, which is useful if you only want to index a subset of a table. SQL Server has the concept of a CLUSTERED INDEX, whereby it stores the rows physically in index sequence. It defaults to using a clustered index for the primary key. Often this is not what you want, so it is desirable to specify the primary key as NONCLUSTERED, and then specify a CLUSTERED index for a more frequently used column. These are just a few of the differences, but you get the idea. If there is a better way to do this in a cross-platform manner, I would love to know how. Thanks Frank -- http://mail.python.org/mailman/listinfo/python-list