Git Product home page Git Product logo

text-to-db-converter's Introduction

dbsql

create a database file first & convert your data that you have in your text file into a database file with these scripts

createdb.py create_database(): This function creates an SQLite database file named db.sqlite and a table called data with columns username and url. It opens a connection to the database, executes the SQL statement to create the table if it does not exist, and then commits the changes and closes the connection.

texttodb.py convert_text_to_sqlite(text_file, sqlite_file): This function reads lines from a text file and inserts the data into an SQLite database table named models. It opens a connection to the SQLite database, creates the table if it does not exist, and then iterates through each line in the text file. If a line contains a space, it assumes it has the format "username url" and splits it to extract the username and url values. It then inserts these values into the models table. If a line does not contain a space, it is skipped as an invalid line. After inserting all the valid lines, the function commits the changes and closes the connection.

To use the scripts, you can simply execute them directly. The createdb.py script will create the database and print a success message, while the texttodb.py script will read the lines from a text file and insert the data into the database, also printing a success message.

text-to-db-converter's People

Contributors

jumbubly avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.