Reputation: 5991
So I have two tables within a Ms Access database that have a common GUID field which I can use to link the two. I would like to create a relationship using the common GUID without having to open up MS Access and create the relationship. I was hoping I could do this with pyodbc since I'm running a pyodbc query already that needs the relationship in order to work correctly. Is this even possibly using pyodbc?
(Incomplete) DDL for existing objects:
CREATE TABLE Customer ( CustID GUID NOT NULL PRIMARY KEY );
CREATE TABLE FileList ( FileID GUID NOT NULL );
What is the syntax for creating a foreign key relationship between the Customer
and FileList
tables, and how can this relationship be created using pyodbc
?
Upvotes: 0
Views: 952
Reputation: 50990
You would do this by constructing an ALTER TABLE command and sending that command to the database.
The exact syntax of that command depends on what kind of relationship(s) you're creating. You'll probably need to create both a PRIMARY KEY on the "one" side of the relationship and FOREIGN KEY on the "many" side.
Upvotes: 1