Objectives A pharmacoepidemiological study to assess VTE risk factors in a diabetes-rich population. Methods The study comprised 299,590 individuals. We observed 3450 VTEs and matched them with 15,875 controls using a nested case-control approach and collected data on comorbidities and prescriptions. By multivariable conditional logistic regression, we calculated ORs with 95%CIs for comorbidities and medications to evaluate their associations with VTE. Results Diabetes (aOR 2.16; 95%CI 1.99–2.34), inflammatory bowel disease (1.84; 1.27–2.66), and severe psychiatric disorders (1.72; 1.43–2.05) had the strongest associations among the non-cancer comorbidities. Pancreatic (12.32; 7.11–21.36), stomach (8.57; 4.07–18.03), lung and bronchus (6.26; 4.16–9.43), and ovarian (6.72; 2.95–15.10) cancers were ranked as high-risk for VTE. Corticosteroids, gabapentinoids, psychotropic drugs, risedronic acid, and pramipexole were most strongly associated (aOR exceeding 1.5) with VTE. Insulin (3.86; 3.33–4.47) and sulphonylureas (2.62; 2.18–3.16) had stronger associations than metformin (1.65; 1.49–1.83). Statins and lercanidipine (0.78; 0.62–0.98) were associated with a lowered risk of VTE. Conclusions In this cohort, with 50% diabetes prevalence, pancreatic, stomach, lung and bronchus, and ovarian cancers were strongly associated with VTE. Corticosteroids, gabapentinoids, and psychotropic medications had the strongest associations with VTE among medications. This may be valuable for generating hypotheses for the further research. Lercanidipine may be a novel protective medication against VTE.