Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

sqlalchemy

How to serialize SqlAlchemy result to JSON?

August 21, 2022 by Magenaut

Django has some good automatic serialization of ORM models returned from DB to JSON format.

Categories Python, Q&A Tags json, python, sqlalchemy Leave a comment

Writing a connection string when password contains special characters

August 20, 2022 by Magenaut

I’m using SQLalchemy for a Python project, and I want to have a tidy connection string to access my database. So for example:

Categories Python, Q&A Tags character-encoding, connection-string, python, sqlalchemy Leave a comment

How to execute raw SQL in Flask-SQLAlchemy app

August 20, 2022 by Magenaut

How do you execute raw SQL in SQLAlchemy?

Categories Python, Q&A Tags flask, flask-sqlalchemy, python, sql, sqlalchemy Leave a comment

Does SQLAlchemy have an equivalent of Django’s get_or_create?

August 19, 2022 by Magenaut

I want to get an object from the database if it already exists (based on provided parameters) or create it if it does not.

Categories Python, Q&A Tags django, python, sqlalchemy Leave a comment

Difference between filter and filter_by in SQLAlchemy

August 19, 2022 by Magenaut

Could anyone explain the difference between filter and filter_by functions in SQLAlchemy?
Which one should I be using?

Categories Python, Q&A Tags python, sqlalchemy Leave a comment

How to write DataFrame to postgres table

August 19, 2022 by Magenaut

There is DataFrame.to_sql method, but it works only for mysql, sqlite and oracle databases. I cant pass to this method postgres connection or sqlalchemy engine.

Categories Python, Q&A Tags pandas, postgresql, python, sqlalchemy Leave a comment

Sqlite / SQLAlchemy: how to enforce Foreign Keys?

August 19, 2022 by Magenaut

The new version of SQLite has the ability to enforce Foreign Key constraints, but for the sake of backwards-compatibility, you have to turn it on for each database connection separately!

Categories Python, Q&A Tags foreign-keys, python, sqlalchemy, sqlite Leave a comment

jsonify a SQLAlchemy result set in Flask

August 19, 2022 by Magenaut

marshmallow is an ORM/ODM/framework-agnostic library for converting
complex datatypes, such as objects, to and from native Python
datatypes.

Categories Python, Q&A Tags flask, flask-sqlalchemy, python, sqlalchemy Leave a comment

Speeding up pandas.DataFrame.to_sql with fast_executemany of pyODBC

August 19, 2022 by Magenaut

I would like to send a large pandas.DataFrame to a remote server running MS SQL. The way I do it now is by converting a data_frame object to a list of tuples and then send it away with pyODBC’s executemany() function. It goes something like this:

Categories Python, Q&A Tags pandas-to-sql, pyodbc, python, sqlalchemy Leave a comment

SQLAlchemy: print the actual query

August 19, 2022 by Magenaut

I’d really like to be able to print out valid SQL for my application, including values, rather than bind parameters, but it’s not obvious how to do this in SQLAlchemy (by design, I’m fairly sure).

Categories Python, Q&A Tags python, sqlalchemy Leave a comment
Older posts
Page1 Page2 … Page5 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress