Re: Threads, introspection, sharing of :memory: databases

[email protected]
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <OFD00DF973.E786A390-ON85257385.00563300-85257385.0056A945@bankofny.com>
Well, there is always querying the sqlite_master table which contains 
table names, but I think that is more work than either one of us is doing 
catching the exception... I just catch a different one :-)

You can look at this thread Gerhard mentions the use of the pragma command 
as well.

http://www.velocityreviews.com/forums/t346194-pysqlite-checking-the-existance-of-a-table.html


Thanks,

Greg Givler
Information Technology
Lockwood®
10 Valley Stream Parkway
Malvern, PA 19355
Phone: (484) 605-4826
Email: [email protected]



[email protected] 
Sent by: pysqlite-bounces-IAPFreCvJWPBWskQ1e/[email protected]
10/31/2007 10:45 AM
Please respond to
pysqlite list <pysqlite-IAPFreCvJWPBWskQ1e/[email protected]>


To
pysqlite list <pysqlite-IAPFreCvJWPBWskQ1e/[email protected]>
cc

Subject
Re: [pysqlite] Threads, introspection, sharing of :memory: databases







    Greg> I am sure there are better ways of doing it, but what I do is
    Greg> simple:

    Greg> def CreateTableFunction()
    Greg>     try:
    Greg>         select ID from foo
    Greg>     except sqlite.DatabaseError:
    Greg>         cur.execute("""CREATE TABLE foo (ID INTEGER PRIMARY KEY, 
FIELD1 VARCHAR(50), FIELD2 VARCHAR(30)""")

    Greg> Works like a charm...

Yes.  Is this any different (logically speaking) than me trying to create
the table and catching the OperationalError though?  I'm used to having 
this
sort of construct available in mysql

    CREATE TABLE IF NOT EXISTS `foo` (
      ...
    );

Does sqlite have the ability to detect if a table already exists?

Thx,

Skip
_______________________________________________
pysqlite mailing list
pysqlite-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/pysqlite

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please call the help desk at ext 4850
______________________________________________________________________


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

_______________________________________________
pysqlite mailing list
pysqlite-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/pysqlite
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.