Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DBMS inventory manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Shrey Patel
DBMS inventory manager
Commits
01ae9124
Commit
01ae9124
authored
1 year ago
by
Shrey Patel
Browse files
Options
Downloads
Patches
Plain Diff
added phase one files
parent
2f34e8f3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
main.py
+28
-0
28 additions, 0 deletions
main.py
phase 1.sql
+84
-0
84 additions, 0 deletions
phase 1.sql
with
112 additions
and
0 deletions
main.py
0 → 100644
+
28
−
0
View file @
01ae9124
import
mysql.connector
from
mysql.connector
import
Error
try
:
connection
=
mysql
.
connector
.
connect
(
host
=
'
localhost
'
,
database
=
'
inventory
'
,
user
=
'
root
'
,
password
=
'
ENTER PASSWORD
'
)
if
connection
.
is_connected
():
db_Info
=
connection
.
get_server_info
()
print
(
"
Connected to MySQL Server version
"
,
db_Info
)
cursor
=
connection
.
cursor
()
cursor
.
execute
(
"
select database();
"
)
record
=
cursor
.
fetchone
()
print
(
"
You
'
re connected to database:
"
,
record
)
cursor
.
execute
(
'
show tables;
'
)
tables
=
cursor
.
fetchall
()
print
(
tables
)
for
i
in
tables
:
print
(
i
)
except
Error
as
e
:
print
(
"
Error while connecting to MySQL
"
,
e
)
finally
:
if
connection
.
is_connected
():
cursor
.
close
()
connection
.
close
()
print
(
"
MySQL connection is closed
"
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
phase 1.sql
0 → 100644
+
84
−
0
View file @
01ae9124
DROP
DATABASE
IF
EXISTS
inventory
;
CREATE
DATABASE
IF
NOT
EXISTS
inventory
;
CREATE
TABLE
IF
NOT
EXISTS
USER
(
pid
INT
AUTO_INCREMENT
,
lname
VARCHAR
(
64
)
NOT
NULL
,
fname
VARCHAR
(
64
)
NOT
NULL
,
password
VARCHAR
(
32
)
NOT
NULL
,
phoneNumber
INT
,
email
VARCHAR
(
128
)
NOT
NULL
,
PRIMARY
KEY
(
pid
)
);
CREATE
TABLE
IF
NOT
EXISTS
ORGANIZATION
(
organizationId
INT
AUTO_INCREMENT
,
name
VARCHAR
(
256
)
NOT
NULL
,
email
VARCHAR
(
128
)
NOT
NULL
,
description
VARCHAR
(
1024
),
ownerPid
INT
NOT
NULL
,
PRIMARY
KEY
(
organizationId
),
CONSTRAINT
fk_user_organization
FOREIGN
KEY
(
ownerPid
)
REFERENCES
USER
(
pid
)
);
CREATE
TABLE
IF
NOT
EXISTS
MANAGER
(
userPid
INT
NOT
NULL
,
organizationId
INT
NOT
NULL
,
PRIMARY
KEY
(
userPid
,
organizationId
),
CONSTRAINT
fk_user_manager
FOREIGN
KEY
(
userPid
)
REFERENCES
USER
(
pid
),
CONSTRAINT
fk_organization_manager
FOREIGN
KEY
(
organizationId
)
REFERENCES
ORGANIZATION
(
organizationId
)
);
CREATE
TABLE
IF
NOT
EXISTS
REQUEST
(
requestId
INT
NOT
NULL
,
userPid
INT
NOT
NULL
,
organizationId
INT
NOT
NULL
,
status
ENUM
(
'PENDING'
,
'ACCEPTED'
,
'DECLINED'
)
NOT
NULL
,
description
VARCHAR
(
256
),
type
ENUM
(
'JOIN'
,
'ITEM'
)
NOT
NULL
,
PRIMARY
KEY
(
requestId
),
CONSTRAINT
fk_user_request
FOREIGN
KEY
(
userPid
)
REFERENCES
USER
(
pid
),
CONSTRAINT
fk_organization_request
FOREIGN
KEY
(
organizationId
)
REFERENCES
ORGANIZATION
(
organizationId
)
);
CREATE
TABLE
IF
NOT
EXISTS
LOCATION
(
locationId
INT
AUTO_INCREMENT
,
location
VARCHAR
(
256
),
organizationId
INT
NOT
NULL
,
PRIMARY
KEY
(
locationId
),
CONSTRAINT
fk_organization_location
FOREIGN
KEY
(
organizationId
)
REFERENCES
ORGANIZATION
(
organizationId
)
);
CREATE
TABLE
IF
NOT
EXISTS
ITEM
(
itemId
INT
AUTO_INCREMENT
,
name
VARCHAR
(
128
)
NOT
NULL
,
description
VARCHAR
(
256
),
ownerPid
INT
,
quantity
INT
NOT
NULL
,
category
VARCHAR
(
128
),
status
ENUM
(
'AVAILABLE'
,
'BORROWED'
,
'LISTED'
,
'SOLD'
)
NOT
NULL
,
locationId
INT
NOT
NULL
,
organizationId
INT
NOT
NULL
,
PRIMARY
KEY
(
itemId
),
CONSTRAINT
fk_location_item
FOREIGN
KEY
(
locationId
)
REFERENCES
LOCATION
(
locationId
),
CONSTRAINT
fk_organiztion_item
FOREIGN
KEY
(
organizationId
)
REFERENCES
ORGANIZATION
(
organizationId
)
);
CREATE
TABLE
IF
NOT
EXISTS
LISTING
(
listingId
INT
AUTO_INCREMENT
,
itemId
INT
NOT
NULL
,
price
DECIMAL
(
6
,
2
)
NOT
NULL
,
status
ENUM
(
'AVAILABLE'
,
'SOLD'
)
NOT
NULL
,
dateListed
TIMESTAMP
DEFAULT
CURRENT_TIMESTAMP
NOT
NULL
,
PRIMARY
KEY
(
listingId
),
CONSTRAINT
fk_item_listing
FOREIGN
KEY
(
itemId
)
REFERENCES
ITEM
(
itemId
)
);
CREATE
TABLE
IF
NOT
EXISTS
FAVORITE
(
userPid
INT
NOT
NULL
,
listingId
INT
NOT
NULL
,
PRIMARY
KEY
(
userPid
,
listingId
),
CONSTRAINT
fk_user_favorite
FOREIGN
KEY
(
userPid
)
REFERENCES
USER
(
pid
),
CONSTRAINT
fk_listing_favorite
FOREIGN
KEY
(
listingId
)
REFERENCES
LISTING
(
listingId
)
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment