Pragmas, foreign keys in sqlite3?

L

llanitedave

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
<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?
 
D

Dennis Lee Bieber

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

<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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top