I am new to python but I have worked with ORM frameworks before.
It is confusing for me that when I create database connection I can specify a database URL to some remote DB.
Or I can create DB in a file without remote DB. How does SQLAlchemy work with a file then?
It doesn`t have an RDBMS to connect to. Only file. So this is the reason for my question:
Is SQLAlchemy an RDBMS itself?
It's not a database, but a library for handling databases, or as they put it:
SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL.
The file based dialect is SQLite.
Related
I am using SQlite db, two application uses this db, one from C++ and another from python. If a table is accessed by both the application simultaneously, Database error occurs. How to use same db in two application. Thanks in advance.
I've an application developed with peewee to use mariadb, but now, I need duplicate the 'insert' to register it in a mssql (Microsft SQL Server) database.
I'm trying to use peewee-mssql and peewee-mssqlserv database drivers (or frameworks, or libraries, i'm confused about how they are called) but it seems that the select and insert functions differ from those defined in original peewee and I don't find documentation or API about this peewee-mssql drivers.
How can I use the same classes to insert records in mariadb and mssql indistinctly? It's possible?
Thanks once again.
I'm trying to connect to our internal Teradata database, using flask and sqlAlchemy along with a custom engine called sqlalchemy teradata. I put the database into the create_engine function likes so.
engine = sqlalchemy.create_engine('teradata://username:pw#server_name/database')
I've setup my dialect just like in the tests
registry.register("tdalchemy", "sqlalchemy_teradata.dialect", "TeradataDialect")
I'm getting a.
DatabaseError: (teradata.api.DatabaseError) (3807, u"[42S02] [Teradata][ODBC Teradata Driver][Teradata Database] Object 'table_name' does not exist
I can make raw sql queries just fine, I can also have alchemy do a query I construct and it pulls the data. I'm not sure what all is preventing things from working properly at all. When I test a similar call but looking at a database in an psql server it works just fine and pulls from that db without issue.
Also the pypi page says there is supposed to be an test/orm_test.py but it doesn't seem to have it.
I have a SQLite database configured with Pyramid Alchemy scaffold in my Linux machine. I have another remote Mysql database which resides in a Windows machine, with loads of data.Now, I have to connect to the remote Mysql database to pull data and populate them into my Sqlite database with the help of sqlAlchemy.
What I had been doing: I used mysql workbench to query data from the mysql database, export results to a csv file, load the csv file into my pyramid initializedb.py through python's default csv module, and then finally insert the retrieved rows into my Sqlite database.
What I want to do: I want to connect to the remote Mysql database from my initializedb.py itself, fetch results and insert them into my sqlite database.
How do I go on about with this? Any help is appreciated.
You can create a connection into your mysql db within the initializedb.py, extract the data and store them into your local db. Now, you will find the basics about sqlalchemy here:
http://docs.sqlalchemy.org/en/rel_0_9/core/tutorial.html
If you need this configurable, then you can put the url of your database into your config and access it through settings.
Also, you do not have to define the structure of your tables exactly, you can use something like:
users = Table('users', metadata, autoload=True)
On the other hand, if your MySQL db structure is the same as the sqlite db structure, it might be possible to reuse your model, but that would probably be hard to explain here without seeing any of your code.
I tried looking in the documentation of Flask and SQLAlchemy but I couldn't find the answer...
Do the sessions used with SQLAlchemy automatically lock the DB? I do a read (let's say it takes a long time) and it seems to block out any other reads I am trying to do on my Postgres DB. Is this something I have to configure manually on Postgres using constraints or is there something I can change with Flask / SQLAlchemy?
Thanks