R
Railway•3mo ago
Tedros

ODBC driver install on Server

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 HOMEBREW_ACCEPT_EULA=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
Install the Microsoft ODBC driver for SQL Server (macOS) - ODBC Dri...
Learn how to install the Microsoft ODBC Driver for SQL Server on macOS clients to enable database connectivity.
GitHub
GitHub - microsoft/homebrew-mssql-release
Contribute to microsoft/homebrew-mssql-release development by creating an account on GitHub.
35 Replies
Percy
Percy•3mo ago
Project ID: c62d9ff5-735f-4436-b815-bf845653279e
Tedros
Tedros•3mo ago
c62d9ff5-735f-4436-b815-bf845653279e
Brody
Brody•3mo ago
could you link the linux install instructions, its safe to say that railway does not run your code on macs
Ayush
Ayush•3mo ago
Sounds like you need a VPS and not PaaS. Why do you need to install the ODBC driver?
Tedros
Tedros•3mo ago
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
Brody
Brody•3mo ago
May I ask why you are using an Microsoft SQL database on Azure as opposed to Postgres on railway?
Tedros
Tedros•3mo 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 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
Brody
Brody•3mo 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
Tedros
Tedros•3mo ago
i like the sound of that lol
Brody
Brody•3mo ago
local development with it is also dead simple using their cli
Tedros
Tedros•3mo 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
Brody
Brody•3mo ago
like docs on how to get your project setup with postgres?
Tedros
Tedros•3mo 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 sorry haven't used railway much until recently and still getting accustomed. i know its a dumb question lol
Brody
Brody•3mo ago
well first open your project and deploy a postgres database
Tedros
Tedros•3mo 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?
Tedros
Tedros•3mo ago
like in here
No description
Brody
Brody•3mo ago
yeah just lookup some examples of a postgres configuration with environment variables because you definitely don't want to hardcode your database credentials like you've shown there
Tedros
Tedros•3mo ago
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
Brody
Brody•3mo ago
pretty sure you would just need to redeploy your database to have another certificate generated after the 820 days. and we generally don't close any forums here!
Tedros
Tedros•3mo ago
you guys are great. really love railway
Brody
Brody•3mo ago
even though I don't work for Railway, I can confidently say that railway loves you too
Tedros
Tedros•3mo ago
its really straightforward. wish more platforms were like this
Brody
Brody•3mo ago
you said it!
Tedros
Tedros•3mo 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 i suppose i can do it through a query
Brody
Brody•3mo 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
Tedros
Tedros•3mo ago
i setup db gate but do i set the postgres volume as the dbgate data or something? yeah the datata already killed one of my tables lol 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
Brody
Brody•3mo ago
you are massively overthinking this, you open dbgate and connect to your database via it's private database url
Tedros
Tedros•3mo ago
oh and then i can just run the create tables scripts and stuff through queries nope definetly still overthinking this ahhhh
Tedros
Tedros•3mo ago
login through herewith postgres private db url?
No description
Tedros
Tedros•3mo ago
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
Brody
Brody•3mo ago
I did mean deploy the template, not download the app, the login details can be found in the dbgate service variables tab
Tedros
Tedros•3mo ago
lol just figured that out cool, thank you getting the actual connection setup in my django project then hopefully good to go
Brody
Brody•3mo ago
sweet
Tedros
Tedros•3mo ago
got everything working yesterday, thanks so much my whole platform is flying now
Brody
Brody•3mo ago
awesome, glad to hear it!