ODBC driver install on Server

tedimcboy
PRO

a year ago

Hi! to connect to a sql database iv'e hosted, the machine my project is running on requires the shared object file libodbc.so.2 when installing ODBC driver. Below are the steps i did to ensure everything worked fine on my local machine, how can I do this on the machine my code is hosted on in railway? is there a way to specify the actual download file and run the commands needed? It's really important that I can get these installed on the railway server, any help at all would be really appreciated. I understand there are limitations, but there has to be a way to get this to work right?

Download ODBC Driver for SQL Server FOR SERVER TO RUN IN DJANGO

https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver16

**Command: **

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
HOMEBREWACCEPTEULA=Y brew install msodbcsql18 mssql-tools18

**May need: **

sudo ln -s /usr/local/etc/odbcinst.ini /etc/odbcinst.ini sudo ln -s /usr/local/etc/odbc.ini /etc/odbc.ini

0 Replies

tedimcboy
PRO

a year ago

c62d9ff5-735f-4436-b815-bf845653279e


a year ago

could you link the linux install instructions, its safe to say that railway does not run your code on macs


ayush-lal
HOBBY

a year ago

Sounds like you need a VPS and not PaaS. Why do you need to install the ODBC driver?


tedimcboy
PRO

a year ago

yeah, just installed the unixodbc driver through home-brew with "brew install unixodbc"


tedimcboy
PRO

a year ago

ok so the deal is that i setup an azure sql server db and to connect to it from my django project WITH django 5.0+ i needed that driver. There are other libraries like django-azure-sql-backend BUT it requires Django<2.2 and >=2.1.0 and that won't work for my project. I'm happy to share my db connection code and all of that, if there is a better way to access my azure sql database from django and be able to host it on railway that would be amazing


tedimcboy
PRO

a year ago

heres an example, when I login to my django project, it checks if creds are in the databse. after entering credentials, im getting "Error loading pyodbc module: libodbc.so.2: cannot open shared object file: No such file or directory" which is my issue. im using this driver to connect to my db

'OPTIONS': {
'driver': 'ODBC Driver 18 for SQL Server',
},

if you have any other suggestions for how to connect to my database with django 5.0+ and not need the odbc driver i would be forever grateful 🙂 thanks so much for even getting back to me


tedimcboy
PRO

a year ago

yeah im looking into that. if there is a way to connect to my db without switching to a VPS i'd like to, but so far i think i may need to just use one


a year ago

May I ask why you are using an Microsoft SQL database on Azure as opposed to Postgres on railway?


tedimcboy
PRO

a year ago

I wasn't initially planning on using railway to host and I liked all the metrics i get with azure + table creation scripts are nice and easy. I haven't tried using a db wtihin railway so i'd have to get familair with it. Is that the best option? I'm storing login info, module progress and some other things


tedimcboy
PRO

a year ago

also would i be able to test locally as well? I understand there are variables and all that in railway but haven't used it in that way yet


a year ago

well yeah you wouldn't get all the fancy metrics with a database on Railway, but it would be absolutely dead simple with no extra configurations needed


tedimcboy
PRO

a year ago

i like the sound of that lol


a year ago

local development with it is also dead simple using their cli


tedimcboy
PRO

a year ago

sweet, are there any docs for railway specific usage? I was looking into a VPS but i'd prefer railway so i think i'll go with postgres


a year ago

like docs on how to get your project setup with postgres?


tedimcboy
PRO

a year ago

i mean with railway, so am i setting up a db within the railway project nd then connecting locally later? or do i just setup with postgres though cli and then connect to that one through railway or


tedimcboy
PRO

a year ago

sorry haven't used railway much until recently and still getting accustomed. i know its a dumb question lol


a year ago

well first open your project and deploy a postgres database


tedimcboy
PRO

a year ago

i did, and then in settings.py of my django project am i setting the db connection string to the public networking field in settings of the db?


tedimcboy
PRO

a year ago

like in here

1222208807665664000


a year ago

yeah just lookup some examples of a postgres configuration with environment variables


a year ago

because you definitely don't want to hardcode your database credentials like you've shown there


tedimcboy
PRO

a year ago

so the SSL cert lasts for 820 days by default right, can we extend/renew that through railway


tedimcboy
PRO

a year ago

i think i got everything going, still testing some things so please don't close this quite yet 🙂 thanks for all the help so far


a year ago

pretty sure you would just need to redeploy your database to have another certificate generated after the 820 days.


a year ago

and we generally don't close any forums here!


tedimcboy
PRO

a year ago

you guys are great. really love railway


a year ago

even though I don't work for Railway, I can confidently say that railway loves you too


tedimcboy
PRO

a year ago

its really straightforward. wish more platforms were like this


a year ago

you said it!


tedimcboy
PRO

a year ago

oh do you knwo if there is an option to modify/delete table contents? i wanted to change the datatype of a column but it appears we can only add data


tedimcboy
PRO

a year ago

i suppose i can do it through a query


a year ago

whatever you do, don't use the data tab as it can and will break your data at some point, i highly recommend dbgate instead


tedimcboy
PRO

a year ago

i setup db gate but do i set the postgres volume as the dbgate data or something?


tedimcboy
PRO

a year ago

yeah the datata already killed one of my tables lol


tedimcboy
PRO

a year ago

just for how to actually make them interface with eachother. i assume we have a db gate service and postgres service, still trying to see how they communicate within the project though


a year ago

you are massively overthinking this, you open dbgate and connect to your database via it's private database url


tedimcboy
PRO

a year ago

oh and then i can just run the create tables scripts and stuff through queries


tedimcboy
PRO

a year ago

nope definetly still overthinking this


tedimcboy
PRO

a year ago

ahhhh


tedimcboy
PRO

a year ago

login through herewith postgres private db url?

1222242549092192300


tedimcboy
PRO

a year ago

never used dbgate before, guessing it is an easy interface for creating tables or something of the sort?


tedimcboy
PRO

a year ago

feel like its the wrong section though. maybe i need an account first and then i'll have the option to connect to a db


tedimcboy
PRO

a year ago

ohh hold up, i downloaded it. can't i just do it from the app? wasn't sure if you meant that i needed the service added into the project or you meant jut logging into the db through the app. sorry for all the questions, just don't want to do this in a crappy way


a year ago

I did mean deploy the template, not download the app, the login details can be found in the dbgate service variables tab


tedimcboy
PRO

a year ago

lol just figured that out


tedimcboy
PRO

a year ago

cool, thank you


tedimcboy
PRO

a year ago

getting the actual connection setup in my django project then hopefully good to go


a year ago

sweet


tedimcboy
PRO

a year ago

got everything working yesterday, thanks so much


tedimcboy
PRO

a year ago

my whole platform is flying now


a year ago

awesome, glad to hear it!