Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Pragmas, foreign keys in sqlite3?

Reply
Thread Tools

Pragmas, foreign keys in sqlite3?

 
 
llanitedave
Guest
Posts: n/a
 
      03-15-2012
Several questions here, but they're related.

I'm trying to incorporate an sqlite3 database that was created using
Sqliteman1.2.2. I don't know what version of sqlite3 that one uses,
but it seems to have ignored any attempts to create foreign keys for
its tables.

I'm using Python 2.7.2, and I know that the sqlite3 version that it
contains is 3.7.7. Therefore, it should be able to handle foreign
keys. Where I'm clueless is about how to get that information out of
it, and how to implement or add foreign keys to existing tables.

Is there some way to use the sqlite PRAGMA command from within python?

I tried connecting to the database and got

>>> cr.execute('''PRAGMA foreign_keys;''')

<sqlite3.Cursor object at 0xb7335720>

using "inspect.getmembers()" I got a huge list of everything; it lets
me see that there's no foreign key created, but I can't get that
particular tuple separated out, and I have no idea how to add them.

Do I need to recreate the entire database structure from scratch?
 
Reply With Quote
 
 
 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      03-15-2012
On Thu, 15 Mar 2012 09:59:54 -0700 (PDT), llanitedave
<(E-Mail Removed)> declaimed the following in
gmane.comp.python.general:

> it, and how to implement or add foreign keys to existing tables.
>

For the most part, SQLite3 doesn't permit any modification to
existing tables; one basically dumps the data, deletes the table,
redefines it with needed changes, reloads the data.

> Is there some way to use the sqlite PRAGMA command from within python?
>
> I tried connecting to the database and got
>
> >>> cr.execute('''PRAGMA foreign_keys;''')

> <sqlite3.Cursor object at 0xb7335720>
>

No surprise there... If any data is returned, you'll need to do a
cr.fetch() (or .fetchall() ).

> Do I need to recreate the entire database structure from scratch?


As mentioned above... essentially...
--
Wulfraed Dennis Lee Bieber AF6VN
http://www.velocityreviews.com/forums/(E-Mail Removed) HTTP://wlfraed.home.netcom.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to link foreign keys & primary keys using python? Harry George Python 9 06-13-2006 06:29 AM
Encrypting confidential data including foreign keys Tom ASP .Net 5 05-18-2006 08:21 PM
Survey - implementing CRUD with "foreign name" instead of foreign key. H5N1 ASP .Net 0 05-03-2006 11:36 PM
ObjectDataSource and Displaying Foreign Keys Nightcrawler ASP .Net 0 11-10-2005 10:34 PM
Middlegen Foreign Keys dan.fanelli@gmail.com Java 0 02-16-2005 04:20 AM



Advertisments