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
**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
a year ago
could you link the linux install instructions, its safe to say that railway does not run your code on macs
Sounds like you need a VPS and not PaaS. Why do you need to install the ODBC driver?
yeah, just installed the unixodbc driver through home-brew with "brew install unixodbc"
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
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
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?
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
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
a year ago
local development with it is also dead simple using their cli
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?
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
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
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?
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
so the SSL cert lasts for 820 days by default right, can we extend/renew that through railway
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!
a year ago
even though I don't work for Railway, I can confidently say that railway loves you too
a year ago
you said it!
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
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
i setup db gate but do i set the postgres volume as the dbgate data or something?
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
oh and then i can just run the create tables scripts and stuff through queries
never used dbgate before, guessing it is an easy interface for creating tables or something of the sort?
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
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
getting the actual connection setup in my django project then hopefully good to go
a year ago
sweet
a year ago
awesome, glad to hear it!