Giter Site home page Giter Site logo

ambertide / datalite Goto Github PK

View Code? Open in Web Editor NEW
16.0 2.0 7.0 5.8 MB

A simple Python library to bind dataclasses with databases.

Home Page: https://datalite.readthedocs.io/en/latest/

License: MIT License

Python 99.82% Shell 0.18%
dataclass sqlite3-database decorator python pypi

datalite's Introduction

Ege Emir Özkan - eambertide

LinkedIn CodePen Itch.io Twitter

Welcome to my GitHub!, I have listed the projects I think are more presentable down below, categorised, some might be still WIP, others I might have collabbed with other people, but all are dear and near to me.

My Projects!

Web Programming 🔗

I have professionally worked as a full-time web developer for more than a year now, if we include part-time, that makes two years, it is hard to keep motivated to learn new stuff when all you do at work is web programming too, but I have been trying to keep myself motivated with small and interesting projects.

Varichromatic flash-verify generate-realm VoynichExplorer

Game Development 🎮

I have interest in Game Development, espacially narrative-driven games, over the years I have experimented with many technologies, wrote an Amnesia custom story with another, have written numerous Choose-Your-Own-Adventure style interactive web games with Inkle, even published some in Google Play once (they aren't there anymore, though.)

My current on-goging project in this area is HailMary, a minimalist, isometric 2D game runtime.

HailMary Hardship BAL-Z Under These Roots It Happened Here

Game Development, but Retro 👾

Senior year of college, I realised I really love Retro Games, this resulted in a series of prototypes and tools to facilitate DOS x86 Choose-Your-Own-Adventure style game development. This led to me actually learning parts of x86 assembly as well as some DOS Interrupts and system calls. I created the following:

Florence Engine Twine2Assembler BMP2VGA pytmm

I also really like Emulator Work, so I have dabbled on that too:

chip8 chip8

Programming Languages 🔨

I am a huge Programming Language nerd! Proud subscriber to r/ProgrammingLanguages, design and implementation of programming languages has always interested me, I have written small interpreters here and there and have penned a proposal for a new programming language, I even implemented parts of it. (CFluxion remains incomplete)

SASVM BrainfuInterpreter uFluxion Fluxion Language Specification

Web Scrapping and API Wrapping 🤖

I know my way around BeautifulSoup and HTML web scrapping, and know how to write wrapper APIs for high-level languages around web APIs, including SOAP APIs.

PyTCID ProximaBNews Silene

Narrative-Driven Experiences 📖

I always liked writing, hence, sometimes I tend to combine my experiences in writing with my programming experience to create unique narratives, websites, alternate reality games, these are listed here.

Rah-i Azap Hayaletli İzmir

PS: This web app was used to generate these repository images

datalite's People

Contributors

ambertide avatar intoverflow avatar mathyba avatar mbyzhang avatar tclancy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

datalite's Issues

Enhancement: proper fetch* type hinting

Current implementation of fetch methods do not type hint objects returned, which makes it more difficult to use.

Suggestion:

Add a TypeVar to fetch.py:

from typing import TypeVar
T = TypeVar('T')

Modify fetch* functions type hinting from:

  def fetch_from(class_: type, obj_id: int) -> Any:

to:

  def fetch_from(class_: type[T], obj_id: int) -> T:

That will give a proper type hint to IDE.

Move away from string interpolation & adopt query parameters

The current implementation uses string interpolation to construct sqlite queries.

See the following for a typical example:

f" VALUES ({', '.join(_convert_sql_format(item[1]) for item in kv_pairs)});")

This causes problems when trying to insert JSON data (or other fancy strings) into a table.

There is another way to pass values into queries: so-called query parameters. Query parameters do not have this same limitation. See cursor-objects (sqlite3).

Handle Optional[] Types

I tried using this with a dataclass which contained a number of types marked Optional[type] and it failed with

datalite/commons.py in _convert_type(type_, type_overload)
     23         return type_overload[type_]
     24     except KeyError:
---> 25         raise TypeError("Requested type not in the default or overloaded type table."

I was able to work around this by defining the fields with default values but it feels like either should work.

BUG: fetch_equals crashes if there are no rows to return

Lines in fetch_equals:

        cur.execute(f"SELECT * FROM {table_name} WHERE {field} = ?;", (value, ))
        obj_id, *field_values = list(cur.fetchone())

crash execution due to None being returned from cur.fetchone() if there are no rows.

A fix could be:

        row = cur.fetchone()
        if not row:
            return None
        obj_id, *field_values = list(row)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.