Code Monkey home page Code Monkey logo

Comments (10)

rwnx avatar rwnx commented on August 23, 2024 3

you should be able to use the date_between provider in the way you mentioned, using the fake_args feature.

column_name: 
  type: fake_update
  fake_type: date_between
  fake_args:
    start_date: "-50y"
    end_date: "-18y"

You can read more about how passing args to generators works in the docs.

Let me know how you get on āœØ

from pynonymizer.

stoiven avatar stoiven commented on August 23, 2024

You prolly can do something with a type literal and then use some sql to generate it @amz4u2nv

from pynonymizer.

amz4u2nv avatar amz4u2nv commented on August 23, 2024

Thanks,
Is there any example, of using this
date_between_dates

from pynonymizer.

stoiven avatar stoiven commented on August 23, 2024

If you're doing >18 age, can you filter via based on the table? Like for example

mysql> select * from person;
+-----+----------+--------+------+
| number | name  | gender | age  |
+-----+----------+--------+------+
| 114    | kev    | m    |  18   |  
| 115    | brian  | m    |  18   | 
+-----+----------+--------+------+

select * from table_name where timestampdiff(year,age,curdate()) > 50

Or something like this

from pynonymizer.

amz4u2nv avatar amz4u2nv commented on August 23, 2024

My bad at not explaining it, Iā€™m trying to generate a fake dob but need the dob to be set so that they are all over 18

from pynonymizer.

amz4u2nv avatar amz4u2nv commented on August 23, 2024

Thanks @rwnx, that did the trick
I was trying to use date_between_dates -
like below

  date_of_birth:
    type: fake_update
    fake_type: date_between_dates
    fake_args:
      start_date: '1975-01-01'
      end_date: '2001-01-01'

but got this error -
Unsupported Fake type: date_between_dates: dict_keys(['start_date', 'end_date'])
Not sure why this didnt work, do you know where the best place to see if my keys are correct and if the date inputs are in the correct format.

Thanks

from pynonymizer.

rwnx avatar rwnx commented on August 23, 2024

So a Unsupported Fake type is thrown when the generator, date_between_dates can't be found in the faker object being used.
can you give me some more info, e.g. your pynonymizer version, the version of faker you have, the locale being used in the strategy/config?

from pynonymizer.

amz4u2nv avatar amz4u2nv commented on August 23, 2024

the version of pynonymizer is 1.21.3
faker 11.3.0
I didn't choose explicity a locale but tried it with and without
pynonymizer -u root -p root -i test1.sql -s table_strategy.yml -o testdumpanon.sql

tables:
applicant_applicant:
columns:
firstName: first_name
lastName: last_name
dateOfBirth:
type: fake_update
fake_type: date_between_dates
fake_args:
start_date: '1975-01-01'
end_date: '2003-01-01'

Also taking out the fake_args in the above example, doesn't show any error, but it requires the params to make it work correctly.

from pynonymizer.

rwnx avatar rwnx commented on August 23, 2024

Ahh, I think i have something for you. date_between_dates and date_between take different kwarg names šŸ˜… (date_start vs start_date)

āš ļø However. I don't think feeding date_between_dates strings will work either, unless the yaml parser supports datetime parsing natively. Can i ask why you want to use date_between_dates / Did you try using date_between? It seems like they'd have the same effect (pynonymizer will be using a string value in the insert/update statement anyway).

from pynonymizer.

amz4u2nv avatar amz4u2nv commented on August 23, 2024

yup that did the trick...my bad, should have spotted that.
date_between work absolutely fine, it was just when i trying to figure out how to resolve it, I came across date_between_dates, and was just wandering why it didn't work for me.

Thanks for all your help, much appreciated.

from pynonymizer.

Related Issues (20)

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.